bofenghuang commited on
Commit
eb937e4
·
1 Parent(s): f0b2cfd

add logger

Browse files
Files changed (2) hide show
  1. run_demo.py +12 -1
  2. run_demo_streaming.py +11 -1
run_demo.py CHANGED
@@ -1,5 +1,14 @@
1
- from transformers import pipeline
 
2
  import gradio as gr
 
 
 
 
 
 
 
 
3
 
4
  pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
5
 
@@ -7,6 +16,7 @@ pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
7
  def transcribe(audio):
8
  # text = pipe(audio, chunk_length_s=30, stride_length_s=5)["text"]
9
  text = pipe(audio)["text"]
 
10
  return text
11
 
12
 
@@ -19,4 +29,5 @@ iface = gr.Interface(
19
  allow_flagging="never",
20
  )
21
 
 
22
  iface.launch()
 
1
+ import logging
2
+
3
  import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ logging.basicConfig(
7
+ format="%(asctime)s [%(levelname)s] [NLU] [Trainer] %(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
 
 
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
 
 
29
  allow_flagging="never",
30
  )
31
 
32
+ # iface.launch(server_name="0.0.0.0", debug=True, share=False)
33
  iface.launch()
run_demo_streaming.py CHANGED
@@ -1,5 +1,14 @@
1
- from transformers import pipeline
 
2
  import gradio as gr
 
 
 
 
 
 
 
 
3
 
4
  pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
5
 
@@ -7,6 +16,7 @@ pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
7
  def transcribe(audio, state=""):
8
  text = pipe(audio, chunk_length_s=5, stride_length_s=1)["text"]
9
  state += text + " "
 
10
  return state, state
11
 
12
 
 
1
+ import logging
2
+
3
  import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ logging.basicConfig(
7
+ format="%(asctime)s [%(levelname)s] [NLU] [Trainer] %(message)s",
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
 
 
16
  def transcribe(audio, state=""):
17
  text = pipe(audio, chunk_length_s=5, stride_length_s=1)["text"]
18
  state += text + " "
19
+ logger.info(f"Transcription for {audio}: {state}")
20
  return state, state
21
 
22