bofenghuang commited on
Commit
9844004
Β·
1 Parent(s): 07fa407

add upload

Browse files
app.py CHANGED
@@ -1 +1 @@
1
- run_demo.py
 
1
+ run_demo_microphone.py
run_demo_file.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
+ import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ logging.basicConfig(
7
+ format="%(asctime)s [%(levelname)s] [%(name)s] %(message)s",
8
+ datefmt="%Y-%m-%dT%H:%M:%SZ",
9
+ )
10
+ logger = logging.getLogger(__name__)
11
+ logger.setLevel(logging.DEBUG)
12
+
13
+ pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
14
+
15
+
16
+ def transcribe(audio):
17
+ # text = pipe(audio, chunk_length_s=30, stride_length_s=5)["text"]
18
+ text = pipe(audio)["text"]
19
+ logger.info(f"Transcription for {audio}: {text}")
20
+ return text
21
+
22
+
23
+ iface = gr.Interface(
24
+ fn=transcribe,
25
+ inputs=gr.Audio(source="upload", type="filepath", label="Upload some audio file..."),
26
+ outputs="text",
27
+ title="Speech-to-Text in French",
28
+ description="Realtime demo for French automatic speech recognition.",
29
+ allow_flagging="never",
30
+ )
31
+
32
+ # iface.launch(server_name="0.0.0.0", debug=True, share=False)
33
+ iface.launch()
run_demo.py β†’ run_demo_microphone.py RENAMED
File without changes
run_demo_streaming.py β†’ run_demo_microphone_streaming.py RENAMED
@@ -8,7 +8,7 @@ logging.basicConfig(
8
  datefmt="%Y-%m-%dT%H:%M:%SZ",
9
  )
10
  logger = logging.getLogger(__name__)
11
- logger.setLevel(logging.INFO)
12
 
13
  pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
14
 
 
8
  datefmt="%Y-%m-%dT%H:%M:%SZ",
9
  )
10
  logger = logging.getLogger(__name__)
11
+ logger.setLevel(logging.DEBUG)
12
 
13
  pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
14