Nuno-Tome commited on
Commit
e97cf3e
1 Parent(s): 164b221
Files changed (2) hide show
  1. app.py +16 -10
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import gradio as gr
2
  import json
 
 
3
  #from bark import SAMPLE_RATE, generate_audio, preload_models
4
  #from bark.generation import SUPPORTED_LANGS
5
  #from share_btn imposrt community_icon_html, loading_icon_html, share_js
@@ -27,11 +29,11 @@ MAX_TEXT_LENGTH = 10000
27
  SUPPORTED_LANGS_BY_APP = ["en", "es", "fr", "it", "pt", "nl"]
28
  SUPPORTED_LANGS_BY_MODEL = ["en", "es", "fr", "it", "pt", "nl"]
29
 
30
- def predict(text, lang, audio, request: gr.Request):
31
 
32
  output_text = {"verdict ": "SUCCESS"} # Initialize as a dictionary
33
- output_text["Text"] = text
34
- output_text["Language"] = lang
35
 
36
  if request:
37
  # Convert headers to a dictionary and include them in the output_text
@@ -40,29 +42,33 @@ def predict(text, lang, audio, request: gr.Request):
40
  if not request:
41
  gr.Warning("No request")
42
  return None
43
- if len(text) < MIN_TEXT_LENGTH:
44
  gr.Warning("Text to short. Please provide a longer text, min " + str(MIN_TEXT_LENGTH)+" characters")
45
  return None
46
- if len(text) > MAX_TEXT_LENGTH:
47
  gr.Warning("Text to long. Please provide a shorter text, max " + str(MAX_TEXT_LENGTH)+" characters")
48
  return None
49
- if lang not in SUPPORTED_LANGS_BY_MODEL:
50
  gr.Warning("Language not supported by the model. Please select a supported language")
51
  return None
52
  else:
53
- if lang not in SUPPORTED_LANGS_BY_APP:
54
  gr.Warning("Language not supported for now. Please select a supported language")
55
  return None
56
 
57
-
 
 
 
 
 
 
58
 
59
  #if not audio:
60
  # gr.Warning("Please provide an audio file")
61
  # return None
62
 
63
 
64
-
65
-
66
  output_text_json = json.dumps(output_text)
67
  return output_text_json
68
 
 
1
  import gradio as gr
2
  import json
3
+ from TTS.api import TTS
4
+
5
  #from bark import SAMPLE_RATE, generate_audio, preload_models
6
  #from bark.generation import SUPPORTED_LANGS
7
  #from share_btn imposrt community_icon_html, loading_icon_html, share_js
 
29
  SUPPORTED_LANGS_BY_APP = ["en", "es", "fr", "it", "pt", "nl"]
30
  SUPPORTED_LANGS_BY_MODEL = ["en", "es", "fr", "it", "pt", "nl"]
31
 
32
+ def predict(input_text, input_lang, audio, request: gr.Request):
33
 
34
  output_text = {"verdict ": "SUCCESS"} # Initialize as a dictionary
35
+ output_text["Text"] = input_text
36
+ output_text["Language"] = input_lang
37
 
38
  if request:
39
  # Convert headers to a dictionary and include them in the output_text
 
42
  if not request:
43
  gr.Warning("No request")
44
  return None
45
+ if len(input_text) < MIN_TEXT_LENGTH:
46
  gr.Warning("Text to short. Please provide a longer text, min " + str(MIN_TEXT_LENGTH)+" characters")
47
  return None
48
+ if len(input_text) > MAX_TEXT_LENGTH:
49
  gr.Warning("Text to long. Please provide a shorter text, max " + str(MAX_TEXT_LENGTH)+" characters")
50
  return None
51
+ if input_lang not in SUPPORTED_LANGS_BY_MODEL:
52
  gr.Warning("Language not supported by the model. Please select a supported language")
53
  return None
54
  else:
55
+ if input_lang not in SUPPORTED_LANGS_BY_APP:
56
  gr.Warning("Language not supported for now. Please select a supported language")
57
  return None
58
 
59
+ #try:
60
+ # tts.tts_to_file(
61
+ # text=input_text,
62
+ # file_path="output.wav",
63
+ # speaker_wav=speaker_wav,
64
+ # language=input_lang
65
+ # )
66
 
67
  #if not audio:
68
  # gr.Warning("Please provide an audio file")
69
  # return None
70
 
71
 
 
 
72
  output_text_json = json.dumps(output_text)
73
  return output_text_json
74
 
requirements.txt CHANGED
@@ -5,3 +5,4 @@ bark
5
  #share_btn
6
  flask
7
  #bark.generation
 
 
5
  #share_btn
6
  flask
7
  #bark.generation
8
+ TTS