Package: openai-game-translator
openai-game-translatorChatGPT API based video game audio translator application and web serviceOverviewA game translation app that uses the ChatGPT API to recognize in-game speech (TODO: and even game visuals) and provide smooth text translations on platforms like Switch and PS5, thanks to the powerful language abilities of GPT.PrerequisitesIf you don't already have local credentials setup for your AWS account, you can follow thisguidefor configuring them using the AWS CLI.Since we use amazon-transcribe SDK, which is built on top of theAWS Common Runtime (CRT), non-standard operating systems may need to compile these libraries themselves.Should at least setAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables and in[default]profile~/.aws/credentials.Also, ensure that you haveportaudio, which is a prerequisite forpyAudiosudoaptinstallportaudio19-dev# linuxbrewinstallportaudio# macosInstallationInstall the latest version from pippipinstallopenai-game-translatorInstall from github repositorygitclonehttps://github.com/Erisae/openai-game-translatorcdopenai-game-translator
makeinstallQuick StartTerminal UsageTo translate audio to text in the terminal, use the commandtranslate. The simplest way to achieve this is throughAWS's real-time media transcription andGPT-based translation, as shown below:translate--openai_key<openai_key>-i<input_language>-o<output_language>aws_live<openai_key>: A validOpenAI API keyis required for inferencing GPT model to translate.<input_language>: Language of the audio to be transcribed.<output_language>: Target language for the translation.aws_live: This option uses the AWS live stream transcription model, allowing the voice data stream to be uploaded to AWS services using the AWS SDK while recording the voice. Other available audio transcription models includeaws_preandxunfei, but they require additional arguments such as--file,--pre_recorded, and audio transcription API tokens fromxunfei.Note thataws_live,aws_pre,xunfeiwork as subcommands. Ensure thatopenai_key,input_languageandoutput_languageare assigned before running these subcommands, as otherwise the argument values might not be recognized correctly.  For more information about how to use the package in command line, refer to thedocumentation.Script UsageIn script, simply passaws_liveto initialize agameTranslator,translator.openai_translation()will translate Chinese audio to English text.importopenaifromgame_translatorimportgameTranslatoropenai.api_key="<openai_key>"translator=gameTranslator("aws_live",input_language="chinese",output_language="english")translator.openai_translation()ExamplesShell xunfei prerecorded exampletranslate--openai_key<openai_key>-oenglish-ichinesexunfei--xunfei_appid<xunfei_appid>--xunfei_apikey<xunfei_apikey>--xunfei_apisecret<xunfei_apisecret>--fileaudio_sample_little.wav--pre_recorded****************************************
Transcriptionmodel:xunfei
Usingprerecordedaudiofile:audio_sample_little.wav
Inputlanguage:chinese
Outputlanguage:english
****************************************
transcriptionsuccess...
科大讯飞是中国最大的智能语音技术提供商。
translationsuccess...
iFlytekisthelargestintelligentvoicetechnologyproviderinChina.
Elapsedtime:3.813secondsScript AWS live exampletranslator=gameTranslator("aws_live")translator.openai_translation()****************************************
Transcriptionmodel:aws_live
Usingprerecordedaudiofile:None
Inputlanguage:chinese
Outputlanguage:english
****************************************
startdetectingaudio...
currentrms:##                  |detectingfinished...
transcriptionsuccess...
明天的期末考试我能考多少
translationsuccess...
HowmuchcanIscoreontomorrow'sfinalexam?
Elapsedtime:9.155secondsContributingSee more atCONTRIBUTING.md