Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,24 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
|
| 3 |
-
subprocess.run(["pip", "install", "datasets"])
|
| 4 |
-
subprocess.run(["pip", "install", "transformers"])
|
| 5 |
-
subprocess.run(["pip", "install", "torch", "torchvision", "torchaudio", "-f", "https://download.pytorch.org/whl/torch_stable.html"])
|
| 6 |
-
|
| 7 |
import gradio as gr
|
| 8 |
-
|
| 9 |
|
| 10 |
-
# Load model and processor
|
| 11 |
-
processor = WhisperProcessor.from_pretrained("openai/whisper-large")
|
| 12 |
-
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large")
|
| 13 |
-
model.config.forced_decoder_ids = None
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
return
|
| 19 |
|
| 20 |
-
|
| 21 |
-
def
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
gr.Interface(fn=transcribe_audio, inputs=audio_input, outputs="text").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import whisper
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
def transcribe_audio(audio_file):
|
| 6 |
+
model = whisper.load_model("base")
|
| 7 |
+
result = model.transcribe(audio_file)
|
| 8 |
+
return result["text"]
|
| 9 |
|
| 10 |
+
|
| 11 |
+
def main():
|
| 12 |
+
audio_input = gr.inputs.Audio(source="upload", type="filepath")
|
| 13 |
+
output_text = gr.outputs.Textbox()
|
| 14 |
|
| 15 |
+
iface = gr.Interface(fn=transcribe_audio, inputs=audio_input,
|
| 16 |
+
outputs=output_text, title="Audio Transcription App",
|
| 17 |
+
description="Upload an audio file and hit the 'Submit'\
|
| 18 |
+
button")
|
| 19 |
|
| 20 |
+
iface.launch()
|
| 21 |
+
|
| 22 |
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
main()
|
|
|