File size: 1,030 Bytes
d1cf1d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
import whisper
import os
def transcribe_audio(audio_file):
if not os.path.exists(audio_file):
print(f"Cannot locate file: {audio_file}")
return "Error: Audio file not found!"
else:
print(f"Processing file: {audio_file}")
model = whisper.load_model("base")
result = model.transcribe(audio_file, fp16=False)
return result["text"]
def main():
audio_input = gr.Audio(sources=["microphone"], type="filepath")
output_text = gr.Textbox(label="Transcription")
iface = gr.Interface(fn=transcribe_audio,
inputs=audio_input,
outputs=output_text,
title="Audio Transcription App",
description="Record an audio file and hit the 'Submit' button"
)
iface.launch(
share=True,
debug=True,
ssr_mode=False,
server_port=7860,
#prevent_thread_lock=True
)
if __name__ == '__main__':
main()
|