Spaces:
Running
Running
Bugs fix
Browse files- app.py +1 -27
- config.json +1 -2
app.py
CHANGED
@@ -13,28 +13,10 @@ with open('config.json', 'r') as f:
|
|
13 |
APP_NAME = config['APP_NAME']
|
14 |
APP_LOGO = config['APP_LOGO']
|
15 |
APP_DESCRIPTION = config['APP_DESCRIPTION']
|
16 |
-
LANGUAGES_URL = config['LANGUAGES_URL']
|
17 |
|
18 |
def contains_only_ascii(input_string):
|
19 |
return all(ord(char) < 128 for char in input_string)
|
20 |
|
21 |
-
def get_iso_languages():
|
22 |
-
response = requests.get(LANGUAGES_URL)
|
23 |
-
soup = BeautifulSoup(response.text, 'html.parser')
|
24 |
-
|
25 |
-
p_tags = soup.find_all('p')
|
26 |
-
|
27 |
-
iso_language_dict = {}
|
28 |
-
|
29 |
-
for p_tag in p_tags[1:]: # Skipping the first <p> which contains the header
|
30 |
-
parts = p_tag.get_text().split()
|
31 |
-
if len(parts) == 2:
|
32 |
-
iso_code, language_name = parts
|
33 |
-
if contains_only_ascii(language_name):
|
34 |
-
iso_language_dict[language_name] = iso_code
|
35 |
-
|
36 |
-
return iso_language_dict
|
37 |
-
|
38 |
def create_temp_file(input_wav):
|
39 |
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
40 |
temp_file.write(input_wav.read())
|
@@ -48,15 +30,11 @@ def update_progress(percent, text):
|
|
48 |
progress_bar.progress(percent)
|
49 |
status_text.text(text)
|
50 |
|
51 |
-
iso_languages = get_iso_languages()
|
52 |
-
languages = list(iso_languages.keys())
|
53 |
-
|
54 |
st.set_page_config(page_title=APP_NAME)
|
55 |
st.title(APP_NAME)
|
56 |
st.image(APP_LOGO, use_column_width=True)
|
57 |
st.markdown(APP_DESCRIPTION)
|
58 |
|
59 |
-
language = st.selectbox('Select a language', languages)
|
60 |
input_wav = st.file_uploader("Upload a WAV file with your voice", type=["wav"])
|
61 |
clone_wav = st.file_uploader("Upload a WAV file with voice to clone", type=["wav"])
|
62 |
|
@@ -71,12 +49,8 @@ if input_wav and clone_wav:
|
|
71 |
temp_input_file = create_temp_file(input_wav)
|
72 |
temp_clone_file = create_temp_file(clone_wav)
|
73 |
|
74 |
-
iso_code = iso_languages[language]
|
75 |
-
|
76 |
-
print(f'Language: {language}')
|
77 |
-
|
78 |
update_progress(0, 'Loading TTS model...')
|
79 |
-
api = TTS(
|
80 |
|
81 |
update_progress(50, 'Generating audio...')
|
82 |
api.voice_conversion_to_file(
|
|
|
13 |
APP_NAME = config['APP_NAME']
|
14 |
APP_LOGO = config['APP_LOGO']
|
15 |
APP_DESCRIPTION = config['APP_DESCRIPTION']
|
|
|
16 |
|
17 |
def contains_only_ascii(input_string):
|
18 |
return all(ord(char) < 128 for char in input_string)
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def create_temp_file(input_wav):
|
21 |
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
22 |
temp_file.write(input_wav.read())
|
|
|
30 |
progress_bar.progress(percent)
|
31 |
status_text.text(text)
|
32 |
|
|
|
|
|
|
|
33 |
st.set_page_config(page_title=APP_NAME)
|
34 |
st.title(APP_NAME)
|
35 |
st.image(APP_LOGO, use_column_width=True)
|
36 |
st.markdown(APP_DESCRIPTION)
|
37 |
|
|
|
38 |
input_wav = st.file_uploader("Upload a WAV file with your voice", type=["wav"])
|
39 |
clone_wav = st.file_uploader("Upload a WAV file with voice to clone", type=["wav"])
|
40 |
|
|
|
49 |
temp_input_file = create_temp_file(input_wav)
|
50 |
temp_clone_file = create_temp_file(clone_wav)
|
51 |
|
|
|
|
|
|
|
|
|
52 |
update_progress(0, 'Loading TTS model...')
|
53 |
+
api = TTS("voice_conversion_models/multilingual/vctk/freevc24")
|
54 |
|
55 |
update_progress(50, 'Generating audio...')
|
56 |
api.voice_conversion_to_file(
|
config.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
{
|
2 |
"APP_NAME": "TTS-Voice-Conversion",
|
3 |
"APP_LOGO": "https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png",
|
4 |
-
"APP_DESCRIPTION": "Simple app that uses [Coqui TTS](https://github.com/coqui-ai/TTS) library make conversion of your voice!"
|
5 |
-
"LANGUAGES_URL": "https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html"
|
6 |
}
|
|
|
1 |
{
|
2 |
"APP_NAME": "TTS-Voice-Conversion",
|
3 |
"APP_LOGO": "https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png",
|
4 |
+
"APP_DESCRIPTION": "Simple app that uses [Coqui TTS](https://github.com/coqui-ai/TTS) library to make conversion of your voice!"
|
|
|
5 |
}
|