# Examples ## Import Library and Set OpenAI ```python import openai from game_translator import gameTranslator openai.api_key = "sk-xxxx" ``` ## AWS live version ```python translator = gameTranslator("aws_live") translator.openai_translation() ``` ```shell **************************************** Transcription model : aws_live Using prerecorded audio file : None Input language : chinese Output language : english **************************************** start detecting audio... current rms: ## | detecting finished... transcription success... 明天的期末考试我能考多少 translation success... How much can I score on tomorrow's final exam? Elapsed time: 9.155 seconds ``` ```eval_rst .. note:: * Once calling `openai_translation()`, an overview of game translator settings would be displayed. * A line with "current rms: " will occur when recording audio, there is a "|" indicating low volume. If "#"s does not surpass "|" for some time, the system considers the end of the speech and stops recording automatically. ``` ## AWS prerecorded version - not using a prerecorded audio file ```python translator = gameTranslator("aws_pre", file_path="./audio/temp.wav", prerecorded=False, output_language="Chinese") translator.openai_translation() ``` ```shell **************************************** Transcription model : aws_pre Using prerecorded audio file : None Temporery audio file generated by [aws_pre] saves at : /Users/arika/Desktop/openai-game-translator/game_translator/audio/temp.wav Input language : chinese Output language : english **************************************** start detecting audio... current rms: ## | detecting finished... transcription success... 啊吗?考试嗯嗯。 translation success... What? Exam, um-hmm. Elapsed time: 22.377 seconds ``` - using a prerecorded audio file ```python translator = gameTranslator("aws_pre", file_path="./audio/audio_sample_little.wav", prerecorded=True) translator.openai_translation() ``` ```shell **************************************** Transcription model : aws_pre Using prerecorded audio file : /Users/arika/Desktop/openai-game-translator/game_translator/audio/audio_sample_little.wav Input language : chinese Output language : english **************************************** transcription success... 科大讯飞是中国最大的智能语音技术提供商。 translation success... iFLYTEK is the largest provider of intelligent speech technology in China. Elapsed time: 6.614 seconds ``` ## Xunfei version - using a prerecorded audio file ```python translator = gameTranslator("xunfei", xunfei_appid="xxx", xunfei_apikey="xxx", xunfei_apisecret="xxx", filepath="./audio/audio_sample_little.wav", prerecorded=True) translator.openai_translaion() ``` ```shell **************************************** Transcription model : xunfei Using prerecorded audio file : /Users/arika/Desktop/openai-game-translator/game_translator/audio/audio_sample_little.wav Input language : chinese Output language : english **************************************** transcription success... 科大讯飞是中国最大的智能语音技术提供商。 translation success... iFlytek is the largest provider of intelligent voice technology in China. Elapsed time: 9.434 seconds ``` - not using a prerecorded audio file ```python translator = gameTranslator("xunfei", xunfei_appid="xxx", xunfei_apikey="xxx", xunfei_apisecret="xxx", filepath="./audio/temp.wav", prerecorded=False) translator.openai_translaion() ```