Spaces:
Runtime error
Runtime error
Download app.py from Manutorresdev96/speech2text_app: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/Manutorresdev96/speech2text_app/resolve/main/app.py
- Command line
-
hf download hf://spaces/Manutorresdev96/speech2text_app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Manutorresdev96/speech2text_app/resolve/main/app.py
966 Bytes
| import torch | |
| from transformers import pipeline | |
| import gradio as gr | |
| import torch | |
| import gradio as gr | |
| def transcript_audio(audio_file): | |
| # Initialize the speech recognition pipeline | |
| pipe = pipeline( | |
| "automatic-speech-recognition", | |
| model="openai/whisper-small", | |
| chunk_length_s=30, | |
| device=0 if torch.cuda.is_available() else -1, | |
| ) | |
| # Transcribe the audio file and return the result | |
| result = pipe(audio_file, batch_size=8)["text"] | |
| return result | |
| # Set up Gradio interface | |
| audio_input = gr.Audio(sources="upload", type="filepath") # Audio input | |
| output_text = gr.Textbox() # Text output | |
| # Create the Gradio interface with the function, inputs, and outputs | |
| iface = gr.Interface(fn=transcript_audio, | |
| inputs=audio_input, outputs=output_text, | |
| title="Audio Transcription App", | |
| description="Upload the audio file") | |
| # Launch the Gradio app | |
| iface.launch() | |