seawolf2357
commited on
Commit
•
c4ad0e3
1
Parent(s):
5888805
Update app.py
Browse files
app.py
CHANGED
@@ -42,14 +42,56 @@ if selected_menu == "Sound" and selected_sub_menu == "TTS(Voice)":
|
|
42 |
st.header("Text-to-Speech")
|
43 |
# 텍스트 입력
|
44 |
text = st.text_area("Enter text to synthesize", "Hello, welcome to ViDraft TTS service.")
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# 'Synthesize' 버튼
|
49 |
if st.button("Synthesize"):
|
50 |
if text:
|
51 |
try:
|
52 |
-
|
|
|
53 |
audio_file = BytesIO()
|
54 |
tts.write_to_fp(audio_file)
|
55 |
audio_file.seek(0)
|
@@ -59,6 +101,8 @@ if selected_menu == "Sound" and selected_sub_menu == "TTS(Voice)":
|
|
59 |
else:
|
60 |
st.warning("Please enter some text to synthesize.")
|
61 |
|
|
|
|
|
62 |
# Pexels API 키 설정
|
63 |
PEXELS_API_KEY = "5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62"
|
64 |
|
|
|
42 |
st.header("Text-to-Speech")
|
43 |
# 텍스트 입력
|
44 |
text = st.text_area("Enter text to synthesize", "Hello, welcome to ViDraft TTS service.")
|
45 |
+
|
46 |
+
# 언어 선택 - 더 많은 언어 추가
|
47 |
+
languages = [
|
48 |
+
("Arabic", "ar-XA"),
|
49 |
+
("Bengali", "bn-IN"),
|
50 |
+
("Chinese, Mandarin (Simplified)", "cmn-CN"),
|
51 |
+
("Chinese, Mandarin (Traditional)", "cmn-TW"),
|
52 |
+
("Danish", "da-DK"),
|
53 |
+
("Dutch", "nl-NL"),
|
54 |
+
("English, Australia", "en-AU"),
|
55 |
+
("English, India", "en-IN"),
|
56 |
+
("English, UK", "en-GB"),
|
57 |
+
("English, US", "en-US"), # 기본값으로 설정될 언어
|
58 |
+
("French", "fr-FR"),
|
59 |
+
("French, Canada", "fr-CA"),
|
60 |
+
("German", "de-DE"),
|
61 |
+
("Gujarati", "gu-IN"),
|
62 |
+
("Hindi", "hi-IN"),
|
63 |
+
("Indonesian", "id-ID"),
|
64 |
+
("Italian", "it-IT"),
|
65 |
+
("Japanese", "ja-JP"),
|
66 |
+
("Kannada", "kn-IN"),
|
67 |
+
("Korean", "ko-KR"),
|
68 |
+
("Malayalam", "ml-IN"),
|
69 |
+
("Marathi", "mr-IN"),
|
70 |
+
("Norwegian", "nb-NO"),
|
71 |
+
("Polish", "pl-PL"),
|
72 |
+
("Portuguese, Brazil", "pt-BR"),
|
73 |
+
("Portuguese, Portugal", "pt-PT"),
|
74 |
+
("Russian", "ru-RU"),
|
75 |
+
("Spanish, Spain", "es-ES"),
|
76 |
+
("Spanish, Mexico", "es-MX"),
|
77 |
+
("Swedish", "sv-SE"),
|
78 |
+
("Tamil", "ta-IN"),
|
79 |
+
("Telugu", "te-IN"),
|
80 |
+
("Thai", "th-TH"),
|
81 |
+
("Turkish", "tr-TR"),
|
82 |
+
("Ukrainian", "uk-UA"),
|
83 |
+
("Vietnamese", "vi-VN"),
|
84 |
+
]
|
85 |
+
# 'English, US'를 기본 언어로 설정
|
86 |
+
default_lang_index = languages.index(("English, US", "en-US"))
|
87 |
+
language = st.selectbox("Choose Language", languages, format_func=lambda x: x[0], index=default_lang_index, key='language_select')
|
88 |
|
89 |
# 'Synthesize' 버튼
|
90 |
if st.button("Synthesize"):
|
91 |
if text:
|
92 |
try:
|
93 |
+
tts_language = dict(languages)[language]
|
94 |
+
tts = gTTS(text=text, lang=tts_language, slow=False)
|
95 |
audio_file = BytesIO()
|
96 |
tts.write_to_fp(audio_file)
|
97 |
audio_file.seek(0)
|
|
|
101 |
else:
|
102 |
st.warning("Please enter some text to synthesize.")
|
103 |
|
104 |
+
|
105 |
+
|
106 |
# Pexels API 키 설정
|
107 |
PEXELS_API_KEY = "5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62"
|
108 |
|