aslanovaf commited on
Commit
c77513d
1 Parent(s): 7c8b033

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -57
app.py CHANGED
@@ -1,62 +1,7 @@
1
- import torch
2
- from transformers import pipeline
3
- from transformers.pipelines.audio_utils import ffmpeg_read
4
  import gradio as gr
5
  import os
6
 
7
- # Accessing HF_TOKEN key from environment variable
8
  hf_token = os.environ.get('HF_TOKEN')
9
 
10
- device = 0 if torch.cuda.is_available() else "cpu"
11
- pipe = pipeline("automatic-speech-recognition", model="aslanovaf/wav2vec2-azekb-latest", token=hf_token)
12
-
13
-
14
- def transcribe(file):
15
- outputs = pipe(file)
16
- text = outputs["text"]
17
- return text
18
-
19
- demo = gr.Blocks()
20
-
21
- mic_transcribe = gr.Interface(
22
- fn=transcribe,
23
- inputs=[
24
- gr.inputs.Audio(source="microphone", type="filepath", optional=True),
25
- ],
26
- outputs="text",
27
- layout="horizontal",
28
- theme="huggingface",
29
- title="Azerbaijani Fine-Tuned Business Demo: Transcribe Audio",
30
- description=(
31
- "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the fine-tuned checkpoint of \
32
- [facebook/mms-1b-all](https://huggingface.co/facebook/mms-1b-all) and 🤗 Transformers to transcribe audio files."
33
- ),
34
- allow_flagging="never",
35
- )
36
-
37
- file_transcribe = gr.Interface(
38
- fn=transcribe,
39
- inputs=[
40
- gr.inputs.Audio(source="upload", optional=True, label="Audio file", type="filepath"),
41
- ],
42
- outputs="text",
43
- layout="horizontal",
44
- theme="huggingface",
45
- title="Azerbaijani Fine-Tuned Business STT Demo: Transcribe Audio",
46
- description=(
47
- "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the fine-tuned checkpoint of \
48
- [facebook/mms-1b-all](https://huggingface.co/facebook/mms-1b-all) and 🤗 Transformers to transcribe audio files."
49
- ),
50
- examples=[
51
- ["./Recording_1.wav", "transcribe"],
52
- ["./Recording_2.wav", "transcribe"],
53
- ["./Recording_3.wav", "transcribe"]
54
- ],
55
- cache_examples=True,
56
- allow_flagging="never",
57
- )
58
-
59
- with demo:
60
- gr.TabbedInterface([mic_transcribe, file_transcribe], ["Transcribe Microphone", "Transcribe Audio File"])
61
-
62
- demo.launch(enable_queue=True)
 
 
 
 
1
  import gradio as gr
2
  import os
3
 
 
4
  hf_token = os.environ.get('HF_TOKEN')
5
 
6
+ iface = gr.load(name="aslanovaf/STT_Azerbaijani", hf_token=hf_token, src="spaces")
7
+ iface.queue(api_open=False).launch(show_api=False)