import gradio as gr from faster_whisper import WhisperModel model_size = "large-v2" model = WhisperModel(model_size, device="cpu", compute_type="int8") def transcribe(audio, state=""): print(audio) segments, info = model.transcribe(audio, beam_size=5) print("Detected language '%s' with probability %f" % (info.language, info.language_probability)) for segment in segments: print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text)) state += segment.text + " " return state, state gr.Interface( fn=transcribe, inputs=[ gr.Audio(source="microphone", type="filepath", streaming=True), "state" ], outputs=[ "textbox", "state" ], live=True).launch()