Functions

class game_translator.game_translator.gameTranslator(transcription_model, filepath='', xunfei_appid='', xunfei_apikey='', xunfei_apisecret='', prerecorded=True, input_language='chinese', output_language='english')

Bases: object

An audio game translator class,

This class provides functinalities for …

filepath

file path for prerecorded audio file or to be recorded.

Type

str

transcription_model

choose from “aws_pre”, “aws_live” and “xunfei”.

Type

str

appid

xunfei transcription appid.

Type

str

apikey

xunfei transcription apikey.

Type

str

apisecret

xunfei transcription apisecret.

Type

str

pre_recorded

whether needs prerecorded audio file.

Type

bool

input_language

transcription input language.

Type

str

output_language

translation output language.

Type

str

aws_live_transcription()

Transcripts audio file with aws_live transcription. Record with pyaudio and send stream to aws simultaneously.

Parameters

None

Returns

transcription result.

Return type

str

aws_prerecored_transcription()

Transcripts audio file with awd_prerecorded transcription, if not self.pre_recorded, record() first.

Parameters

None

Returns

transcription result.

Return type

str

openai_translation()

Translates text to target language using openai.

Parameters

None

Returns

translation result.

Return type

str

record_audio()

Detects and records audio using pyaudio, saves at self.filepath.

Parameters

None

Returns

None

show_time()

Show elapsed time for transcription and translation, including audio recording.

Parameters

None

Returns

None

show_translator_info()

Show basic configurations of translator.

Parameters

None

Returns

None

xunfei_transcription()

Transcripts audio file with xunfei speed transcription, if not self.pre_recorded, record() first.

Parameters

None

Returns

transcription result.

Return type

str

game_translator.game_translator.main()

main() function that takes cmd line input to instantiate and run a translator.