davabase / whisper_real_time

Real time transcription with OpenAI Whisper.
2.32k stars 394 forks source link

auto translation? #6

Open cameronbergh opened 1 year ago

cameronbergh commented 1 year ago

I am fairly sure that this model is capable of translating non-english spoken language into english text. I think maybe we are missing a parameter perhaps? how can we make this translate non_english speech into english text?

davabase commented 1 year ago

I didn't add this as a parameter but Whisper does support translation. You can change line 124 from:

result = audio_model.transcribe(temp_file, fp16=torch.cuda.is_available())

to

result = audio_model.transcribe(temp_file, fp16=torch.cuda.is_available(), task='translate')

and make sure you're using the generic model by passing in --non_english as a parameter.

Whisper also supports specifying the language, which supposedly does a better job than the auto-language detect. You can pass in a language with the language argument:

result = audio_model.transcribe(temp_file, fp16=torch.cuda.is_available(), task='translate', language='es')

The languages available are listed here in the Whisper source.

These are features I added to my more complete GUI app, Transcriber.