Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
def process_audio(audio_file):
|
| 6 |
+
if audio_file is None:
|
| 7 |
+
return "Please upload an audio file."
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
result = transcribe_audio(audio_file)
|
| 11 |
+
return f"**Transcription:**\\n{result['text']}\\n\\n**Language:** {result['language']}"
|
| 12 |
+
except Exception as e:
|
| 13 |
+
return f"Error processing audio: {str(e)}"
|
| 14 |
+
|
| 15 |
+
# Create Gradio interface
|
| 16 |
+
demo = gr.Interface(
|
| 17 |
+
fn=process_audio,
|
| 18 |
+
inputs=gr.Audio(type="filepath"),
|
| 19 |
+
outputs=gr.Markdown(),
|
| 20 |
+
title="Whisper.cpp Speech-to-Text",
|
| 21 |
+
description="Upload an audio file to transcribe it using Whisper.cpp (local processing)",
|
| 22 |
+
examples=[
|
| 23 |
+
# Add example audio files here
|
| 24 |
+
]
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|
| 28 |
+
|