Spaces:
Runtime error
Runtime error
| import whisper | |
| import gradio as gr | |
| import time | |
| from pyChatGPT import ChatGPT | |
| import warnings | |
| from gtts import gTTS | |
| warnings.filterwarnings("ignore") | |
| # model = whisper.load_model("base") | |
| model = whisper.load_model("base") | |
| def transcribe(audio): | |
| # load audio and pad/trim it to fit 30 seconds | |
| audio = whisper.load_audio(audio) | |
| audio = whisper.pad_or_trim(audio) | |
| # make log-Mel spectrogram and move to the same device as the model | |
| mel = whisper.log_mel_spectrogram(audio).to(model.device) | |
| # decode the audio | |
| options = whisper.DecodingOptions(fp16=False) | |
| result = whisper.decode(model, mel, options) | |
| result_text = result.text | |
| # print the result | |
| return result_text | |
| output_1 = gr.Textbox(label="Speech to Text") | |
| gr.Interface( | |
| title = 'Voice to Text (KF)', | |
| fn=transcribe, | |
| inputs=[ | |
| gr.inputs.Audio(source="microphone", type="filepath") | |
| ], | |
| outputs=[ | |
| output_1 | |
| ], | |
| live=True, allow_flagging=False).launch(share=False) |