Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -75,19 +75,15 @@ def driver_fun(audio) :
|
|
75 |
print(f"lower_limit : upper_limit = {lower_limit} : {upper_limit}")
|
76 |
dataset_subset = dataset['Joke'][lower_limit : upper_limit]
|
77 |
data = query({"inputs": {"source_sentence": "That is a happy person","sentences": dataset_subset} } )
|
|
|
|
|
78 |
print(f"type(data) : {type(data)}")
|
79 |
print(f"data : {data} ")
|
80 |
max_match_score = max(data)
|
81 |
indx_score = data.index(max_match_score)
|
82 |
joke = data[indx_score]
|
83 |
-
|
84 |
-
#For now only taking in English text for Bloom prompting as inference model is not high spec
|
85 |
-
#text_generated = lang_model_response(transcribe, lang)
|
86 |
-
#text_generated_en = lang_model_response(translation, 'en')
|
87 |
|
88 |
-
#if lang in ['es', 'fr']:
|
89 |
-
# speech = tts(transcribe, lang)
|
90 |
-
#else:
|
91 |
speech = tts(joke, 'en') #'en' # translation
|
92 |
return translation, joke, speech #transcribe,
|
93 |
|
@@ -123,9 +119,10 @@ def whisper_stt(audio):
|
|
123 |
# Coqui - Text-to-Speech
|
124 |
def tts(text, language):
|
125 |
print(f"Inside tts - language is : {language}")
|
126 |
-
coqui_langs = ['en' ,'es' ,'fr' ,'de' ,'pl' ,'uk' ,'ro' ,'hu' ,'bg' ,'nl' ,'fi' ,'sl' ,'lv' ,'ga']
|
127 |
-
if language not in coqui_langs:
|
128 |
-
|
|
|
129 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
130 |
coquiTTS.get_tts(text, fp, speaker = {"language" : language})
|
131 |
return fp.name
|
|
|
75 |
print(f"lower_limit : upper_limit = {lower_limit} : {upper_limit}")
|
76 |
dataset_subset = dataset['Joke'][lower_limit : upper_limit]
|
77 |
data = query({"inputs": {"source_sentence": "That is a happy person","sentences": dataset_subset} } )
|
78 |
+
if 'error' in data:
|
79 |
+
return 'Error in model inference - Run Again Please', 'Error in model inference - Run Again Please', None
|
80 |
print(f"type(data) : {type(data)}")
|
81 |
print(f"data : {data} ")
|
82 |
max_match_score = max(data)
|
83 |
indx_score = data.index(max_match_score)
|
84 |
joke = data[indx_score]
|
85 |
+
print(f"Joke is : {joke}")
|
|
|
|
|
|
|
86 |
|
|
|
|
|
|
|
87 |
speech = tts(joke, 'en') #'en' # translation
|
88 |
return translation, joke, speech #transcribe,
|
89 |
|
|
|
119 |
# Coqui - Text-to-Speech
|
120 |
def tts(text, language):
|
121 |
print(f"Inside tts - language is : {language}")
|
122 |
+
#coqui_langs = ['en' ,'es' ,'fr' ,'de' ,'pl' ,'uk' ,'ro' ,'hu' ,'bg' ,'nl' ,'fi' ,'sl' ,'lv' ,'ga']
|
123 |
+
#if language not in coqui_langs:
|
124 |
+
# language = 'en'
|
125 |
+
print(f"Text is : {text}")
|
126 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
127 |
coquiTTS.get_tts(text, fp, speaker = {"language" : language})
|
128 |
return fp.name
|