Spaces:
Runtime error
Runtime error
Commit
·
2118e30
1
Parent(s):
df81534
fixed
Browse files- app.py +42 -42
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -42,7 +42,7 @@ def transcribe(inputs, task, return_timestamps, language):
|
|
| 42 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
| 43 |
|
| 44 |
# Map the language names to their corresponding codes
|
| 45 |
-
language_codes = {"English": "en", "Uzbek": "
|
| 46 |
language_code = language_codes.get(language, "en") # Default to "en" if the language is not found
|
| 47 |
result = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task, "language": f"<|{language_code}|>"},
|
| 48 |
return_timestamps=return_timestamps)
|
|
@@ -107,7 +107,7 @@ def yt_transcribe(yt_url, task, return_timestamps, language, max_filesize=75.0):
|
|
| 107 |
inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
|
| 108 |
|
| 109 |
# Map the language names to their corresponding codes
|
| 110 |
-
language_codes = {"English": "en", "Uzbek":
|
| 111 |
language_code = language_codes.get(language, "en") # Default to "en" if the language is not found
|
| 112 |
|
| 113 |
result = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task, "language": f"<|{language_code}|>"},
|
|
@@ -121,32 +121,32 @@ def yt_transcribe(yt_url, task, return_timestamps, language, max_filesize=75.0):
|
|
| 121 |
|
| 122 |
demo = gr.Blocks()
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
|
| 143 |
file_transcribe = gr.Interface(
|
| 144 |
fn=transcribe,
|
| 145 |
inputs=[
|
| 146 |
-
gr.Audio(
|
| 147 |
-
gr.Radio(["transcribe", "translate"], label="Task"),
|
| 148 |
-
gr.Checkbox(label="Return timestamps"),
|
| 149 |
-
gr.Dropdown(choices=["English", "Uzbek"], label="Language"),
|
| 150 |
],
|
| 151 |
outputs="text",
|
| 152 |
layout="horizontal",
|
|
@@ -159,24 +159,24 @@ file_transcribe = gr.Interface(
|
|
| 159 |
allow_flagging="never",
|
| 160 |
)
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
|
| 181 |
with demo:
|
| 182 |
gr.TabbedInterface([mf_transcribe, file_transcribe, yt_transcribe], ["Microphone", "Audio file", "YouTube"])
|
|
|
|
| 42 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
| 43 |
|
| 44 |
# Map the language names to their corresponding codes
|
| 45 |
+
language_codes = {"English": "en", "Uzbek": "uz"}
|
| 46 |
language_code = language_codes.get(language, "en") # Default to "en" if the language is not found
|
| 47 |
result = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task, "language": f"<|{language_code}|>"},
|
| 48 |
return_timestamps=return_timestamps)
|
|
|
|
| 107 |
inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
|
| 108 |
|
| 109 |
# Map the language names to their corresponding codes
|
| 110 |
+
language_codes = {"English": "en", "Uzbek": "uz"}
|
| 111 |
language_code = language_codes.get(language, "en") # Default to "en" if the language is not found
|
| 112 |
|
| 113 |
result = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task, "language": f"<|{language_code}|>"},
|
|
|
|
| 121 |
|
| 122 |
demo = gr.Blocks()
|
| 123 |
|
| 124 |
+
mf_transcribe = gr.Interface(
|
| 125 |
+
fn=transcribe,
|
| 126 |
+
inputs=[
|
| 127 |
+
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
| 128 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 129 |
+
gr.inputs.Checkbox(label="Return timestamps"),
|
| 130 |
+
gr.inputs.Dropdown(choices=["English", "Uzbek"], label="Language"),
|
| 131 |
+
],
|
| 132 |
+
outputs="text",
|
| 133 |
+
layout="horizontal",
|
| 134 |
+
theme="huggingface",
|
| 135 |
+
title="Whisper Large V3 Uzbek: Transcribe Audio",
|
| 136 |
+
description=(
|
| 137 |
+
"\n\n"
|
| 138 |
+
"<center>⭐️Brought to you by <a href='https://note.com/sangmin/n/n9813f2064a6a'>Chiomirai School</a>⭐️</center>"
|
| 139 |
+
),
|
| 140 |
+
allow_flagging="never",
|
| 141 |
+
)
|
| 142 |
|
| 143 |
file_transcribe = gr.Interface(
|
| 144 |
fn=transcribe,
|
| 145 |
inputs=[
|
| 146 |
+
gr.inputs.Audio(source="upload", type="filepath", optional=True, label="Audio file"),
|
| 147 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 148 |
+
gr.inputs.Checkbox(label="Return timestamps"),
|
| 149 |
+
gr.inputs.Dropdown(choices=["English", "Uzbek"], label="Language"),
|
| 150 |
],
|
| 151 |
outputs="text",
|
| 152 |
layout="horizontal",
|
|
|
|
| 159 |
allow_flagging="never",
|
| 160 |
)
|
| 161 |
|
| 162 |
+
yt_transcribe = gr.Interface(
|
| 163 |
+
fn=yt_transcribe,
|
| 164 |
+
inputs=[
|
| 165 |
+
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
|
| 166 |
+
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 167 |
+
gr.inputs.Checkbox(label="Return timestamps"),
|
| 168 |
+
gr.inputs.Dropdown(choices=["English", "Uzbek"], label="Language"),
|
| 169 |
+
],
|
| 170 |
+
outputs=["html", "text"],
|
| 171 |
+
layout="horizontal",
|
| 172 |
+
theme="huggingface",
|
| 173 |
+
title="Whisper Large V3 Uzbek: Transcribe YouTube",
|
| 174 |
+
description=(
|
| 175 |
+
"\n\n"
|
| 176 |
+
"<center>⭐️Brought to you by <a href='https://note.com/sangmin/n/n9813f2064a6a'>Chiomirai School</a>⭐️</center>"
|
| 177 |
+
),
|
| 178 |
+
allow_flagging="never",
|
| 179 |
+
)
|
| 180 |
|
| 181 |
with demo:
|
| 182 |
gr.TabbedInterface([mf_transcribe, file_transcribe, yt_transcribe], ["Microphone", "Audio file", "YouTube"])
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
git+https://github.com/huggingface/transformers
|
| 2 |
torch
|
| 3 |
yt-dlp
|
| 4 |
-
gradio
|
|
|
|
| 1 |
git+https://github.com/huggingface/transformers
|
| 2 |
torch
|
| 3 |
yt-dlp
|
| 4 |
+
gradio==3.36.1
|