projekt-rising-ai commited on
Commit
791faa5
·
1 Parent(s): 5d59bd9

Removed references to whisper

Browse files
Files changed (1) hide show
  1. app.py +0 -45
app.py CHANGED
@@ -9,9 +9,7 @@ import boto3
9
  import gradio as gr
10
  import requests
11
 
12
- # UNCOMMENT TO USE WHISPER
13
  import warnings
14
- import whisper
15
 
16
  from langchain import ConversationChain, LLMChain
17
 
@@ -75,56 +73,13 @@ AZURE_VOICE_DATA = AzureVoiceData()
75
 
76
  # Pertains to WHISPER functionality
77
  WHISPER_DETECT_LANG = "Detect language"
78
-
79
- # UNCOMMENT TO USE WHISPER
80
  warnings.filterwarnings("ignore")
81
- WHISPER_MODEL = whisper.load_model("tiny")
82
- print("WHISPER_MODEL", WHISPER_MODEL)
83
-
84
-
85
- # UNCOMMENT TO USE WHISPER
86
- def transcribe(aud_inp, whisper_lang):
87
- if aud_inp is None:
88
- return ""
89
- aud = whisper.load_audio(aud_inp)
90
- aud = whisper.pad_or_trim(aud)
91
- mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
92
- _, probs = WHISPER_MODEL.detect_language(mel)
93
- options = whisper.DecodingOptions()
94
- if whisper_lang != WHISPER_DETECT_LANG:
95
- whisper_lang_code = POLLY_VOICE_DATA.get_whisper_lang_code(whisper_lang)
96
- options = whisper.DecodingOptions(language=whisper_lang_code)
97
- result = whisper.decode(WHISPER_MODEL, mel, options)
98
- print("result.text", result.text)
99
- result_text = ""
100
- if result and result.text:
101
- result_text = result.text
102
- return result_text
103
 
104
 
105
  # Temporarily address Wolfram Alpha SSL certificate issue
106
  ssl._create_default_https_context = ssl._create_unverified_context
107
 
108
 
109
- # TEMPORARY FOR TESTING
110
- def transcribe_dummy(aud_inp_tb, whisper_lang):
111
- if aud_inp_tb is None:
112
- return ""
113
- # aud = whisper.load_audio(aud_inp)
114
- # aud = whisper.pad_or_trim(aud)
115
- # mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
116
- # _, probs = WHISPER_MODEL.detect_language(mel)
117
- # options = whisper.DecodingOptions()
118
- # options = whisper.DecodingOptions(language="ja")
119
- # result = whisper.decode(WHISPER_MODEL, mel, options)
120
- result_text = "Whisper will detect language"
121
- if whisper_lang != WHISPER_DETECT_LANG:
122
- whisper_lang_code = POLLY_VOICE_DATA.get_whisper_lang_code(whisper_lang)
123
- result_text = f"Whisper will use lang code: {whisper_lang_code}"
124
- print("result_text", result_text)
125
- return aud_inp_tb
126
-
127
-
128
  # Pertains to Express-inator functionality
129
  def transform_text(desc, express_chain, num_words, formality,
130
  anticipation_level, joy_level, trust_level,
 
9
  import gradio as gr
10
  import requests
11
 
 
12
  import warnings
 
13
 
14
  from langchain import ConversationChain, LLMChain
15
 
 
73
 
74
  # Pertains to WHISPER functionality
75
  WHISPER_DETECT_LANG = "Detect language"
 
 
76
  warnings.filterwarnings("ignore")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
 
79
  # Temporarily address Wolfram Alpha SSL certificate issue
80
  ssl._create_default_https_context = ssl._create_unverified_context
81
 
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  # Pertains to Express-inator functionality
84
  def transform_text(desc, express_chain, num_words, formality,
85
  anticipation_level, joy_level, trust_level,