Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: pink
|
5 |
-
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: huggingface
|
3 |
+
app_file: speech.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 4.21.0
|
|
|
|
|
6 |
---
|
|
|
|
speech.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Build a shareable app with Gradio
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
asr = pipeline(task="automatic-speech-recognition",
|
5 |
+
model="distil-whisper/distil-small.en")
|
6 |
+
|
7 |
+
|
8 |
+
import os
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
demo = gr.Blocks()
|
12 |
+
|
13 |
+
def transcribe_speech(filepath):
|
14 |
+
if filepath is None:
|
15 |
+
gr.Warning("No audio found, please retry.")
|
16 |
+
return ""
|
17 |
+
output = asr(filepath)
|
18 |
+
return output["text"]
|
19 |
+
|
20 |
+
mic_transcribe = gr.Interface(
|
21 |
+
fn=transcribe_speech,
|
22 |
+
inputs=gr.Audio(sources="microphone",
|
23 |
+
type="filepath"),
|
24 |
+
outputs=gr.Textbox(label="Transcription",
|
25 |
+
lines=3),
|
26 |
+
allow_flagging="never")
|
27 |
+
|
28 |
+
file_transcribe = gr.Interface(
|
29 |
+
fn=transcribe_speech,
|
30 |
+
inputs=gr.Audio(sources="upload",
|
31 |
+
type="filepath"),
|
32 |
+
outputs=gr.Textbox(label="Transcription",
|
33 |
+
lines=3),
|
34 |
+
allow_flagging="never",
|
35 |
+
)
|
36 |
+
|
37 |
+
with demo:
|
38 |
+
gr.TabbedInterface(
|
39 |
+
[mic_transcribe,
|
40 |
+
file_transcribe],
|
41 |
+
["Transcribe Microphone",
|
42 |
+
"Transcribe Audio File"],
|
43 |
+
)
|
44 |
+
|
45 |
+
demo.launch(share=True,
|
46 |
+
server_port=int(os.environ.get('PORT1',8080)))
|
47 |
+
|
48 |
+
demo.close()
|
49 |
+
'''
|
50 |
+
|
51 |
+
import soundfile as sf
|
52 |
+
import io
|
53 |
+
audio, sampling_rate = sf.read('output.wav')
|
54 |
+
print(audio.shape)
|
55 |
+
'''
|