MikeTangoEcho commited on
Commit
3ccf873
1 Parent(s): f5ddb49

fix: app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -1,8 +1,15 @@
1
- import torch
2
- import numpy as np
3
  import gradio as gr
4
- from transformers import pipeline
 
 
5
  from pathlib import Path
 
 
 
 
 
 
 
6
 
7
  # Pipelines
8
 
@@ -44,6 +51,8 @@ def transcribe(audio: str | Path | bytes | tuple[int, np.ndarray] | None):
44
  return "..."
45
  # TODO Manage str/Path
46
 
 
 
47
  text = ""
48
  # https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline.__call__
49
  # Whisper input format for tuple differ from output provided by gradio audio component
@@ -52,7 +61,12 @@ def transcribe(audio: str | Path | bytes | tuple[int, np.ndarray] | None):
52
  transcript = asr(inputs)
53
  text = transcript['text']
54
 
 
 
55
  entities = tc(text)
 
 
 
56
  # TODO Add Text Classification for sentiment analysis
57
  return {"text": text, "entities": entities}
58
 
 
 
 
1
  import gradio as gr
2
+ import numpy as np
3
+ import torch
4
+ import transformers
5
  from pathlib import Path
6
+ from transformers import pipeline
7
+ from transformers.utils import logging
8
+
9
+ # Log
10
+
11
+ #logging.set_verbosity_debug()
12
+ logger = logging.get_logger("transformers")
13
 
14
  # Pipelines
15
 
 
51
  return "..."
52
  # TODO Manage str/Path
53
 
54
+ logger.debug("Transcribe")
55
+
56
  text = ""
57
  # https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline.__call__
58
  # Whisper input format for tuple differ from output provided by gradio audio component
 
61
  transcript = asr(inputs)
62
  text = transcript['text']
63
 
64
+ logger.debug("Tokenize:[" + text + "]")
65
+
66
  entities = tc(text)
67
+
68
+ #logger.debug("Classify:[" + entities + "]")
69
+
70
  # TODO Add Text Classification for sentiment analysis
71
  return {"text": text, "entities": entities}
72