gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.37k stars 2.26k forks source link

Speech to text output text box issue #8307

Closed monishreddye closed 1 month ago

monishreddye commented 1 month ago

Describe the bug

I am working on whisper speech to text, I have two option for user for converting speech to text, microphone and audio file. once audio or microphone is on when user speaks, output text box saying error same for when audio file uploaded and click on submit.

Have you searched existing issues? πŸ”Ž

Reproduction

import gradio as gr

''' import whisper

You can choose your model from - see it on readme file and update the modelname

modelname = "base" model = whisper.load_model(modelname)

import gradio as gr import time

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)
print(f"Detected language: {max(probs, key=probs.get)}")

# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)
return result.text

interface = gr.Interface( fn=transcribe, inputs=[gr.Audio(), gr.File()], # Microphone and file options, no source argument outputs="text", description="Speech to Text for Medical Summarization" )

interface.launch()

'''

Screenshot

gradio output textbox gradio output textbox

Logs

No response

System Info

Latest version 4.29.0

Severity

Blocking usage of gradio

abidlabs commented 1 month ago

Hi @monishreddye can you please clarify what the error is, and correct the formatting of your code so that we can repro?

abidlabs commented 1 month ago

Closing for now, we can reopen with more details