Spaces:
Runtime error
Runtime error
Commit
β’
f70f966
1
Parent(s):
5279914
Upload 3 files
Browse files- README.md +5 -3
- app.py +45 -0
- requirements.txt +9 -0
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
-
title: Whisper
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.12.0
|
@@ -11,3 +11,5 @@ license: apache-2.0
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
1 |
---
|
2 |
+
title: Whisper-offline
|
3 |
+
emoji: π
|
4 |
+
colorFrom: red
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.12.0
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
|
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Thu Dec 8 17:37:44 2022
|
4 |
+
|
5 |
+
@author: Kenneth
|
6 |
+
"""
|
7 |
+
|
8 |
+
from transformers import pipeline
|
9 |
+
import gradio as gr
|
10 |
+
from pytube import YouTube
|
11 |
+
from datasets import Dataset, Audio
|
12 |
+
import os
|
13 |
+
from moviepy.editor import AudioFileClip
|
14 |
+
import time
|
15 |
+
|
16 |
+
pipe = pipeline(model="YuhangDeng123/whisper-small-hi") # change to "your-username/the-name-you-picked"
|
17 |
+
|
18 |
+
def transcribe(audio):
|
19 |
+
text = pipe(audio)["text"]
|
20 |
+
return text
|
21 |
+
|
22 |
+
with gr.Blocks() as demo:
|
23 |
+
gr.Markdown("Whisper-Small Cantonese Recognition")
|
24 |
+
with gr.Row():
|
25 |
+
with gr.TabItem("Upload An Audio File"):
|
26 |
+
upload_file = gr.Audio(source="upload", type="filepath",label="Upload An Audio File")
|
27 |
+
upload_button = gr.Button("Submit")
|
28 |
+
upload_outputs = [gr.Textbox(label="Recognized result from uploaded audio file"),]
|
29 |
+
with gr.Row():
|
30 |
+
with gr.TabItem("Record from Microphone"):
|
31 |
+
record_file = gr.Audio(source="microphone", type="filepath",label="Record from microphone")
|
32 |
+
record_button = gr.Button("Submit")
|
33 |
+
record_outputs = [gr.Textbox(label="Recognized result from Microphone"),]
|
34 |
+
upload_button.click(
|
35 |
+
fn=transcribe,
|
36 |
+
inputs=upload_file,
|
37 |
+
outputs=upload_outputs,
|
38 |
+
)
|
39 |
+
|
40 |
+
record_button.click(
|
41 |
+
fn=transcribe,
|
42 |
+
inputs=record_file,
|
43 |
+
outputs=record_outputs,
|
44 |
+
)
|
45 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|
4 |
+
git+https://github.com/pytube/pytube
|
5 |
+
datasets
|
6 |
+
torchaudio
|
7 |
+
librosa
|
8 |
+
jiwer
|
9 |
+
moviepy
|