Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| import time | |
| # Load the pipeline | |
| pipe = pipeline("automatic-speech-recognition") # You can specify model if needed | |
| # Define the transcribe function | |
| def transcribe(audio, state): | |
| time.sleep(1) # simulate delay | |
| text = pipe(audio)["text"] | |
| state += text + " " | |
| return state, state | |
| # Create the Gradio interface | |
| with gr.Blocks() as demo: | |
| state = gr.State("") # Proper state handling | |
| audio_input = gr.Audio(sources="microphone", type="filepath", label="Speak") | |
| output_text = gr.Textbox(label="Transcription") | |
| transcribe_button = gr.Button("Transcribe") | |
| transcribe_button.click( | |
| fn=transcribe, | |
| inputs=[audio_input, state], | |
| outputs=[output_text, state] | |
| ) | |
| demo.launch() | |