Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,14 @@ import os
|
|
5 |
import time
|
6 |
import soundfile as sf
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
welcome_message = """
|
9 |
# Welcome to Tonic's Unity On Device!
|
10 |
|
@@ -14,27 +22,13 @@ Tonic's Unity On Device!🚀 on your own data & in your own way by cloning
|
|
14 |
TeamTonic is always making cool demos! Join our active builder's community on Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On ðŸŒGithub: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)"
|
15 |
"""
|
16 |
|
17 |
-
# Define the list of target languages
|
18 |
-
languages = {
|
19 |
-
"English": "eng",
|
20 |
-
"Hindi": "hin",
|
21 |
-
"Portuguese": "por",
|
22 |
-
"Russian": "rus",
|
23 |
-
"Spanish": "spa"
|
24 |
-
}
|
25 |
|
26 |
def save_audio(audio_input, output_dir="saved_audio"):
|
27 |
if not os.path.exists(output_dir):
|
28 |
os.makedirs(output_dir)
|
29 |
-
|
30 |
-
# Extract sample rate and audio data
|
31 |
sample_rate, audio_data = audio_input
|
32 |
-
|
33 |
-
# Generate a unique file name
|
34 |
file_name = f"audio_{int(time.time())}.wav"
|
35 |
file_path = os.path.join(output_dir, file_name)
|
36 |
-
|
37 |
-
# Save the audio file
|
38 |
sf.write(file_path, audio_data, sample_rate)
|
39 |
|
40 |
return file_path
|
|
|
5 |
import time
|
6 |
import soundfile as sf
|
7 |
|
8 |
+
languages = {
|
9 |
+
"English": "eng",
|
10 |
+
"Hindi": "hin",
|
11 |
+
"Portuguese": "por",
|
12 |
+
"Russian": "rus",
|
13 |
+
"Spanish": "spa"
|
14 |
+
}
|
15 |
+
|
16 |
welcome_message = """
|
17 |
# Welcome to Tonic's Unity On Device!
|
18 |
|
|
|
22 |
TeamTonic is always making cool demos! Join our active builder's community on Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On ðŸŒGithub: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)"
|
23 |
"""
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def save_audio(audio_input, output_dir="saved_audio"):
|
27 |
if not os.path.exists(output_dir):
|
28 |
os.makedirs(output_dir)
|
|
|
|
|
29 |
sample_rate, audio_data = audio_input
|
|
|
|
|
30 |
file_name = f"audio_{int(time.time())}.wav"
|
31 |
file_path = os.path.join(output_dir, file_name)
|
|
|
|
|
32 |
sf.write(file_path, audio_data, sample_rate)
|
33 |
|
34 |
return file_path
|