Spaces:
Paused
Paused
Modernize: Gradio 6.29, Python 3.12, CPU torch, add ffmpeg, file paths
Browse files- README.md +2 -1
- app.py +6 -5
- packages.txt +1 -0
- requirements.txt +2 -2
README.md
CHANGED
|
@@ -4,7 +4,8 @@ emoji: 📚
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.29.0
|
| 8 |
+
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
app.py
CHANGED
|
@@ -6,11 +6,13 @@ model = whisper.load_model("base")
|
|
| 6 |
|
| 7 |
def transcribe_audio(audio_file):
|
| 8 |
# Check file size (e.g., 25MB limit)
|
| 9 |
-
if
|
|
|
|
|
|
|
| 10 |
return "Error: File size exceeds 25MB limit.", None
|
| 11 |
|
| 12 |
-
result = model.transcribe(audio_file
|
| 13 |
-
output_filename = os.path.splitext(os.path.basename(audio_file
|
| 14 |
|
| 15 |
with open(output_filename, "w") as text_file:
|
| 16 |
text_file.write(result["text"])
|
|
@@ -19,7 +21,6 @@ def transcribe_audio(audio_file):
|
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=transcribe_audio,
|
| 22 |
-
theme="Nymbo/Nymbo_Theme",
|
| 23 |
inputs=gr.File(label="Upload Audio File (Max 25MB)"),
|
| 24 |
outputs=[
|
| 25 |
gr.Textbox(label="Transcription"),
|
|
@@ -29,4 +30,4 @@ iface = gr.Interface(
|
|
| 29 |
description="Upload an audio file (WAV, MP3, etc.) up to 25MB to get its transcription. The transcript will be displayed and available for download. Please use responsibly."
|
| 30 |
)
|
| 31 |
|
| 32 |
-
iface.launch(
|
|
|
|
| 6 |
|
| 7 |
def transcribe_audio(audio_file):
|
| 8 |
# Check file size (e.g., 25MB limit)
|
| 9 |
+
if not audio_file:
|
| 10 |
+
return "Error: please upload a file.", None
|
| 11 |
+
if os.path.getsize(audio_file) > 25 * 1024 * 1024:
|
| 12 |
return "Error: File size exceeds 25MB limit.", None
|
| 13 |
|
| 14 |
+
result = model.transcribe(audio_file)
|
| 15 |
+
output_filename = os.path.splitext(os.path.basename(audio_file))[0] + ".txt"
|
| 16 |
|
| 17 |
with open(output_filename, "w") as text_file:
|
| 18 |
text_file.write(result["text"])
|
|
|
|
| 21 |
|
| 22 |
iface = gr.Interface(
|
| 23 |
fn=transcribe_audio,
|
|
|
|
| 24 |
inputs=gr.File(label="Upload Audio File (Max 25MB)"),
|
| 25 |
outputs=[
|
| 26 |
gr.Textbox(label="Transcription"),
|
|
|
|
| 30 |
description="Upload an audio file (WAV, MP3, etc.) up to 25MB to get its transcription. The transcript will be displayed and available for download. Please use responsibly."
|
| 31 |
)
|
| 32 |
|
| 33 |
+
iface.launch(theme="Nymbo/Nymbo_Theme")
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
|
| 2 |
openai-whisper
|
| 3 |
-
torch
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
openai-whisper
|
| 3 |
+
torch
|