From fe048d50009abe0eb79b35519fbda230ae338f52 Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 6 Nov 2022 12:54:54 -0800 Subject: Add language flag to transcription CLI --- transcribe.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transcribe.py b/transcribe.py index 4014dc8..e96d794 100644 --- a/transcribe.py +++ b/transcribe.py @@ -54,7 +54,7 @@ class AudioState: transcribe_no_change_count = 0 transcribe_sleep_duration = transcribe_sleep_duration_min_s # The language the user is speaking in. - language = whisper.tokenizer.TO_LANGUAGE_CODE["japanese"] + language = whisper.tokenizer.TO_LANGUAGE_CODE["english"] # When the user says `over`, we stop displaying new transcriptions until # they clear the board again. @@ -273,12 +273,17 @@ def sendAudio(audio_state): if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--mic", type=str, help="Which mic to use. Options: index, focusrite. Default: index") + parser.add_argument("--language", type=str, help="Which language to use. Ex: english, japanese, chinese, french, german.") args = parser.parse_args() if not args.mic: args.mic = "index" + if not args.language: + args.language = "english" + audio_state = getMicStream(args.mic) + audio_state.language = whisper.tokenizer.TO_LANGUAGE_CODE[args.language] if os.path.isfile(audio_state.VOICE_AUDIO_FILENAME): # empty out the voice file -- cgit v1.2.3