Spaces:
Runtime error
Runtime error
import whisper | |
import gradio as gr | |
import time | |
from pyChatGPT import ChatGPT | |
import warnings | |
model = whisper.load_model("base") | |
#print(model.device) | |
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) | |
# detect the spoken language | |
_, probs = model.detect_language(mel) | |
# decode the audio | |
options = whisper.DecodingOptions() | |
result = whisper.decode(model, mel, options) | |
result_text = result.text | |
# Pass the generated text to Audio | |
chatgpt_api = ChatGPT(email='bratanmol@gmail.com', password='vq3!a^iRKr') | |
resp = chatgpt_api.send_message(result_text) | |
out_result = resp['message'] | |
return [result_text, out_result] | |
output_1 = gr.outputs.Textbox(label="Speech to Text") | |
output_2 = gr.outputs.Textbox(label="ChatGPT Output") | |
gr.Interface( | |
title = 'OpenAI Whisper and ChatGPT ASR Gradio Web UI', | |
fn=transcribe, | |
inputs=[ | |
gr.inputs.Audio(source="microphone", type="filepath") | |
], | |
outputs=[ | |
output_1, output_2 | |
], | |
live=True).launch(inline=False) |