ANYANTUDRE commited on
Commit
1c7cbff
·
1 Parent(s): 1885a88

app almost ready

Browse files
.gitignore CHANGED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # My dirs
2
+ exples_voix/
3
+ audios/
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
114
+ .pdm.toml
115
+ .pdm-python
116
+ .pdm-build/
117
+
118
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
119
+ __pypackages__/
120
+
121
+ # Celery stuff
122
+ celerybeat-schedule
123
+ celerybeat.pid
124
+
125
+ # SageMath parsed files
126
+ *.sage.py
127
+
128
+ # Environments
129
+ .env
130
+ .venv
131
+ env/
132
+ venv/
133
+ .venv/
134
+ ENV/
135
+ env.bak/
136
+ venv.bak/
137
+
138
+ # Spyder project settings
139
+ .spyderproject
140
+ .spyproject
141
+
142
+ # Rope project settings
143
+ .ropeproject
144
+
145
+ # mkdocs documentation
146
+ /site
147
+
148
+ # mypy
149
+ .mypy_cache/
150
+ .dmypy.json
151
+ dmypy.json
152
+
153
+ # Pyre type checker
154
+ .pyre/
155
+
156
+ # pytype static type analyzer
157
+ .pytype/
158
+
159
+ # Cython debug symbols
160
+ cython_debug/
161
+
162
+ # PyCharm
163
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
164
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
165
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
166
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
167
+ #.idea/
app.py CHANGED
@@ -1,15 +1,9 @@
1
- import spaces
2
- import torch
3
- import scipy
4
- import torchaudio
5
-
6
  import gradio as gr
7
- from transformers import pipeline, set_seed
8
  from huggingface_hub import login
9
 
10
  import os
11
  from languages import get_language_names
12
- from goai_helpers import goai_traduction, goai_stt, goai_stt2, goai_tts, goai_tts2
13
 
14
 
15
  auth_token = os.getenv('HF_SPACE_TOKEN')
@@ -18,7 +12,7 @@ login(token=auth_token)
18
 
19
  # list all files in the ./audios directory for the dropdown
20
  AUDIO_FILES = [f for f in os.listdir('./exples_voix') if os.path.isfile(os.path.join('./exples_voix', f))]
21
-
22
  DESCRIPTION = """<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;">
23
  <div style="flex: 1; min-width: 250px;">
24
  Ce modèle de traduction vers la <b>langue Mooré</b> a été développé from scratch par <b>GO AI CORP</b> et la version disponible en test est celle à 700 millions de paramètres.
@@ -52,8 +46,26 @@ LANG_TO_ID = {
52
 
53
  demo = gr.Blocks(theme=gr.themes.Ocean())
54
 
55
- goai_stt = gr.Interface(
56
- fn=goai_stt2.goai_stt2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  inputs=[
58
  gr.Audio(sources=["microphone", "upload"], type="filepath"),
59
  gr.Dropdown(
@@ -76,23 +88,38 @@ goai_stt = gr.Interface(
76
  ["./audios/example4.mp3", "yõk foto"]
77
  ],
78
  cache_examples=False,
79
- title="Mooré ASR: Transcribe Audio",
80
  description=DESCRIPTION,
81
  flagging_mode="auto",
82
  )
83
 
84
- goai_tts = gr.Interface(
85
- fn=goai_tts2.goai_ttt_tts,
86
  inputs=[
87
- gr.Text(label="Texte à traduire", lines=2, value="Par cette ouverture, le centre se veut contribuer à la formation professionnelle des jeunes et des femmes, renforcer les capacités des acteurs du monde agricole, et contribuer à la lutte contre le chômage au Burkina Faso."),
88
- gr.Dropdown(label="Voix", choices=audio_files, value="exple_voix_masculine.wav"),
89
- gr.Audio(label="Cloner votre voix (optionel)", type="numpy", format="wav"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ],
91
  outputs=[
92
  gr.Text(label="Texte traduit"),
93
- gr.Audio(label="Audio original généré", format="wav"),
94
- gr.Audio(label="Denoised Audio", format='wav'),
95
- gr.Audio(label="Enhanced Audio", format='wav')
96
  ],
97
  examples=[["Ils vont bien, merci. Mon père travaille dur dans les champs et ma mère est toujours occupée à la maison.", "exple_voix_masculine.wav", None],
98
  ["La finale s’est jouée en présence du Président du Faso, Ibrahim Traoré.", "exple_voix_feminine.wav", None],
@@ -104,29 +131,31 @@ goai_tts = gr.Interface(
104
  description=DESCRIPTION,
105
  )
106
 
107
- goai_traduction = gr.Interface(
108
- fn=goai_traduction.goai_traduction,
 
109
  inputs=[
110
- gr.Textbox(label="Texte", placeholder="Yaa sõama"),
111
- gr.Dropdown(label="Langue source", choices=["fra_Latn", "mos_Latn"], value='fra_Latn'),
112
- gr.Dropdown(label="Langue cible", choices=["fra_Latn", "mos_Latn"], value='mos_Latn')
113
- ],
114
- outputs=["text"],
115
- examples=[["Yʋʋm a wãn la b kẽesd biig lekolle?", "mos_Latn", "fra_Latn"],
116
- ["Zak-soab la kasma.", "mos_Latn", "fra_Latn"],
117
- ["Le gouvernement avait pris des mesures louables par rapport à l’augmentation des prix de certaines denrées alimentaires.", "fra_Latn", "mos_Latn"],
118
- ["Comme lors du match face à la Côte d’Ivoire, c’est sur un coup de pied arrêté que les Etalons encaissent leur but.", "fra_Latn", "mos_Latn"],
119
  ],
 
 
 
 
 
 
120
  cache_examples=False,
121
- title="Traduction du Mooré: texte vers texte",
122
- description=DESCRIPTION
 
123
  )
124
 
125
-
126
  with demo:
127
  gr.TabbedInterface(
128
- interface_list=[goai_stt, goai_tts, goai_traduction],
129
- tab_names=["Microphone & Audio file"]
130
  )
131
 
132
- demo.queue().launch(ssr_mode=False)
 
 
 
 
 
 
1
  import gradio as gr
 
2
  from huggingface_hub import login
3
 
4
  import os
5
  from languages import get_language_names
6
+ from goai_helpers import goai_traduction, goai_stt, goai_stt2, goai_tts, goai_tts2, goai_ttt_tts_pipeline, goai_stt_ttt_pipeline
7
 
8
 
9
  auth_token = os.getenv('HF_SPACE_TOKEN')
 
12
 
13
  # list all files in the ./audios directory for the dropdown
14
  AUDIO_FILES = [f for f in os.listdir('./exples_voix') if os.path.isfile(os.path.join('./exples_voix', f))]
15
+ MODELES_TTS = ["ArissBandoss/coqui-tts-moore-V1", "ArissBandoss/mms-tts-mos-V18"]
16
  DESCRIPTION = """<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;">
17
  <div style="flex: 1; min-width: 250px;">
18
  Ce modèle de traduction vers la <b>langue Mooré</b> a été développé from scratch par <b>GO AI CORP</b> et la version disponible en test est celle à 700 millions de paramètres.
 
46
 
47
  demo = gr.Blocks(theme=gr.themes.Ocean())
48
 
49
+ goai_traduction_if = gr.Interface(
50
+ fn=goai_traduction.goai_traduction,
51
+ inputs=[
52
+ gr.Textbox(label="Texte", placeholder="Yaa sõama"),
53
+ gr.Dropdown(label="Langue source", choices=["fra_Latn", "mos_Latn"], value='fra_Latn'),
54
+ gr.Dropdown(label="Langue cible", choices=["fra_Latn", "mos_Latn"], value='mos_Latn')
55
+ ],
56
+ outputs=["text"],
57
+ examples=[["Yʋʋm a wãn la b kẽesd biig lekolle?", "mos_Latn", "fra_Latn"],
58
+ ["Zak-soab la kasma.", "mos_Latn", "fra_Latn"],
59
+ ["Le gouvernement avait pris des mesures louables par rapport à l’augmentation des prix de certaines denrées alimentaires.", "fra_Latn", "mos_Latn"],
60
+ ["Comme lors du match face à la Côte d’Ivoire, c’est sur un coup de pied arrêté que les Etalons encaissent leur but.", "fra_Latn", "mos_Latn"],
61
+ ],
62
+ cache_examples=False,
63
+ title="Traduction Mooré-Francais",
64
+ description=DESCRIPTION
65
+ )
66
+
67
+ goai_stt_if = gr.Interface(
68
+ fn=goai_stt2.transcribe,
69
  inputs=[
70
  gr.Audio(sources=["microphone", "upload"], type="filepath"),
71
  gr.Dropdown(
 
88
  ["./audios/example4.mp3", "yõk foto"]
89
  ],
90
  cache_examples=False,
91
+ title="Mooré ASR",
92
  description=DESCRIPTION,
93
  flagging_mode="auto",
94
  )
95
 
96
+ goai_ttt_tts_pipeline_if = gr.Interface(
97
+ fn=goai_ttt_tts_pipeline.goai_ttt_tts,
98
  inputs=[
99
+ gr.Text(
100
+ label="Texte à traduire",
101
+ lines=3,
102
+ value="Par cette ouverture, le centre se veut contribuer à la formation professionnelle des jeunes et des femmes, renforcer les capacités des acteurs du monde agricole, et contribuer à la lutte contre le chômage au Burkina Faso."
103
+ ),
104
+ gr.Dropdown(
105
+ label="Modèles de TTS",
106
+ choices=MODELES_TTS,
107
+ value="ArissBandoss/coqui-tts-moore-V1"
108
+ ),
109
+ gr.Dropdown(
110
+ label="Voix",
111
+ choices=AUDIO_FILES,
112
+ value="exple_voix_masculine.wav"
113
+ ),
114
+ gr.Audio(
115
+ label="Cloner votre voix (optionel)",
116
+ type="numpy",
117
+ format="wav"
118
+ ),
119
  ],
120
  outputs=[
121
  gr.Text(label="Texte traduit"),
122
+ gr.Audio(label="Audio généré", format="wav"),
 
 
123
  ],
124
  examples=[["Ils vont bien, merci. Mon père travaille dur dans les champs et ma mère est toujours occupée à la maison.", "exple_voix_masculine.wav", None],
125
  ["La finale s’est jouée en présence du Président du Faso, Ibrahim Traoré.", "exple_voix_feminine.wav", None],
 
131
  description=DESCRIPTION,
132
  )
133
 
134
+
135
+ goai_stt_ttt_pipeline_if = gr.Interface(
136
+ fn=goai_stt_ttt_pipeline.goai_stt_ttt,
137
  inputs=[
138
+ gr.Audio(sources=["microphone", "upload"], type="filepath"),
139
+ gr.Slider(label="Batch Size", minimum=1, maximum=32, value=8, step=1),
140
+ gr.Slider(label="Chunk Length (s)", minimum=1, maximum=60, value=17.5, step=0.1),
141
+ gr.Slider(label="Stride Length (s)", minimum=1, maximum=30, value=1, step=0.1),
 
 
 
 
 
142
  ],
143
+ outputs=[gr.Textbox(label="Output"), gr.File(label="Download Files")],
144
+ examples=[["./audios/example1.mp3", "a ye ligdi"],
145
+ ["./audios/example2.mp3", "zoe nimbãanega"],
146
+ ["./audios/example3.mp3", "zãng-zãnga"],
147
+ ["./audios/example4.mp3", "yõk foto"]
148
+ ],
149
  cache_examples=False,
150
+ title="Mooré ASR",
151
+ description=DESCRIPTION,
152
+ flagging_mode="auto",
153
  )
154
 
 
155
  with demo:
156
  gr.TabbedInterface(
157
+ interface_list=[goai_traduction_if, goai_stt_if, goai_ttt_tts_pipeline_if, goai_stt_ttt_pipeline_if],
158
+ tab_names=["Traduction Mooré-Francais", "Mooré ASR", "Mooré TTS & Traduction", "Mooré ASR & Traduction"]
159
  )
160
 
161
+ demo.queue().launch(ssr_mode=False)
goai_helpers/goai_stt2.py CHANGED
@@ -6,7 +6,15 @@ DEVICE = 0 if torch.cuda.is_available() else "cpu"
6
 
7
 
8
  @spaces.GPU
9
- def transcribe(inputs, model, language, batch_size, chunk_length_s, stride_length_s):
 
 
 
 
 
 
 
 
10
  if inputs is None:
11
  raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
12
 
 
6
 
7
 
8
  @spaces.GPU
9
+ def transcribe(
10
+ inputs,
11
+ model,
12
+ language,
13
+ batch_size,
14
+ chunk_length_s,
15
+ stride_length_s
16
+ ):
17
+
18
  if inputs is None:
19
  raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
20
 
goai_helpers/goai_stt_ttt_pipeline.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import spaces
3
+ from huggingface_hub import login
4
+
5
+ from goai_helpers.goai_traduction import goai_traduction
6
+ from goai_helpers.goai_stt2 import transcribe
7
+
8
+ # authentification
9
+ auth_token = os.getenv('HF_SPACE_TOKEN')
10
+ login(token=auth_token)
11
+
12
+ MODEL_ASR = "ArissBandoss/whisper-small-mos"
13
+ LANGUAGE = "Automatic Detection"
14
+
15
+
16
+ # gradio interface translation and text to speech function
17
+ @spaces.GPU(duration=120)
18
+ def goai_stt_ttt(
19
+ inputs,
20
+ batch_size,
21
+ chunk_length_s,
22
+ stride_length_s,
23
+ model=MODEL_ASR,
24
+ language=LANGUAGE,
25
+ ):
26
+
27
+ # 1. STT: Speech To Text
28
+ mos_text = transcribe(
29
+ inputs,
30
+ batch_size,
31
+ chunk_length_s,
32
+ stride_length_s,
33
+ model=model,
34
+ language=language,
35
+ )
36
+ yield mos_text, None
37
+
38
+ # 2. TTT: Translation mos ==> fr
39
+ fr_text = goai_traduction.goai_traduction(
40
+ mos_text,
41
+ src_lang="fra_Latn",
42
+ tgt_lang="mos_Latn"
43
+ )
44
+ yield mos_text, fr_text
goai_helpers/goai_traduction.py CHANGED
@@ -3,10 +3,10 @@ import spaces
3
  from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer
4
  import os
5
  from huggingface_hub import login
 
6
  max_length = 512
7
  auth_token = os.getenv('HF_SPACE_TOKEN')
8
  login(token=auth_token)
9
- #auth_token = os.environ["HF_SPACE_TOKEN"]
10
 
11
 
12
  @spaces.GPU
 
3
  from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer
4
  import os
5
  from huggingface_hub import login
6
+
7
  max_length = 512
8
  auth_token = os.getenv('HF_SPACE_TOKEN')
9
  login(token=auth_token)
 
10
 
11
 
12
  @spaces.GPU
goai_helpers/goai_tts2.py CHANGED
@@ -1,23 +1,16 @@
1
  import os
2
- import re
3
  import time
4
  import torch
5
  import torchaudio
6
  import spaces
7
- import requests
8
  import tempfile
9
- import concurrent
10
- import numpy as np
11
  from tqdm import tqdm
12
  from typing import Optional, Tuple
13
  from huggingface_hub import hf_hub_download, hf_hub_url, login
14
 
15
- from TTS.tts.layers.xtts.tokenizer import VoiceBpeTokenizer
16
  from TTS.tts.configs.xtts_config import XttsConfig
17
  from TTS.tts.models.xtts import Xtts
18
 
19
- from resemble_enhance.enhancer.inference import denoise, enhance
20
- from flore200_codes import flores_codes
21
  from goai_helpers.utils import download_file, diviser_phrases_moore, enhance_speech
22
  from goai_helpers.goai_traduction import goai_traduction
23
 
@@ -284,7 +277,11 @@ def goai_ttt_tts(
284
  ):
285
 
286
  # translation
287
- mos_text = goai_traduction.goai_traduction(text, src_lang="fra_Latn", tgt_lang="mos_Latn")
 
 
 
 
288
  yield mos_text, None, None, None
289
 
290
  # TTS pipeline
@@ -310,4 +307,4 @@ def goai_ttt_tts(
310
  denoise_before_enhancement
311
  )
312
 
313
- yield mos_text, (sampling_rate, audio_array.numpy()), denoised_audio, enhanced_audio
 
1
  import os
 
2
  import time
3
  import torch
4
  import torchaudio
5
  import spaces
 
6
  import tempfile
 
 
7
  from tqdm import tqdm
8
  from typing import Optional, Tuple
9
  from huggingface_hub import hf_hub_download, hf_hub_url, login
10
 
 
11
  from TTS.tts.configs.xtts_config import XttsConfig
12
  from TTS.tts.models.xtts import Xtts
13
 
 
 
14
  from goai_helpers.utils import download_file, diviser_phrases_moore, enhance_speech
15
  from goai_helpers.goai_traduction import goai_traduction
16
 
 
277
  ):
278
 
279
  # translation
280
+ mos_text = goai_traduction(
281
+ text,
282
+ src_lang="fra_Latn",
283
+ tgt_lang="mos_Latn"
284
+ )
285
  yield mos_text, None, None, None
286
 
287
  # TTS pipeline
 
307
  denoise_before_enhancement
308
  )
309
 
310
+ yield mos_text, (sampling_rate, audio_array.numpy()), denoised_audio, enhanced_audio
goai_helpers/goai_ttt_tts_pipeline.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ import spaces
4
+ from huggingface_hub import login
5
+
6
+ from goai_helpers.goai_traduction import goai_traduction
7
+ from goai_helpers.goai_tts2 import MooreTTS, text_to_speech
8
+ from goai_helpers.goai_tts import goai_tts
9
+
10
+
11
+ # authentification
12
+ auth_token = os.getenv('HF_SPACE_TOKEN')
13
+ login(token=auth_token)
14
+
15
+
16
+ # gradio interface text to speech function
17
+ @spaces.GPU
18
+ def goai_many_tts(
19
+ text,
20
+ tts_model,
21
+ reference_speaker,
22
+ reference_audio=None,
23
+ ):
24
+
25
+ if tts_model == "ArissBandoss/coqui-tts-moore-V1":
26
+ # TTS pipeline
27
+ tts = MooreTTS(tts_model)
28
+ reference_speaker = os.path.join("./exples_voix", reference_speaker)
29
+
30
+ # convert translated text to speech with reference audio
31
+ if reference_audio is not None:
32
+ audio_array, sampling_rate = text_to_speech(tts, text, reference_speaker, reference_audio)
33
+ else:
34
+ audio_array, sampling_rate = text_to_speech(tts, text, reference_speaker=reference_speaker)
35
+
36
+ return text, (sampling_rate, audio_array.numpy())
37
+
38
+ elif tts_model == "ArissBandoss/mms-tts-mos-V18":
39
+ sample_rate, audio_data = goai_tts(text)
40
+ return text, (sample_rate, audio_data)
41
+
42
+ else:
43
+ print("Erreur de modèle!!! Veuillez vérifier le modèle sélectionné.")
44
+
45
+
46
+ # gradio interface translation and text to speech function
47
+ @spaces.GPU(duration=120)
48
+ def goai_ttt_tts(
49
+ text,
50
+ tts_model,
51
+ reference_speaker,
52
+ reference_audio=None,
53
+ ):
54
+
55
+ # 1. TTT: Translation fr ==> mos
56
+ mos_text = goai_traduction.goai_traduction(
57
+ text,
58
+ src_lang="fra_Latn",
59
+ tgt_lang="mos_Latn"
60
+ )
61
+ yield mos_text, None
62
+
63
+ # 2. TTS: Text to Speech
64
+ sample_rate, audio_data = goai_many_tts(
65
+ text,
66
+ tts_model,
67
+ reference_speaker,
68
+ reference_audio=reference_audio,
69
+ )
70
+ yield mos_text, (sample_rate, audio_data)