Vo Hoang Minh commited on
Commit ·
bcdb708
1
Parent(s): 038f7a1
- pkg/tts_run.py +12 -2
- requirements.txt +2 -1
pkg/tts_run.py
CHANGED
|
@@ -7,6 +7,7 @@ import tempfile
|
|
| 7 |
import edge_tts
|
| 8 |
import pysubs2
|
| 9 |
import requests
|
|
|
|
| 10 |
|
| 11 |
VOICES = ['en-US', 'ja-JP', 'ko-KR', 'zh-CN', 'vi-VN']
|
| 12 |
|
|
@@ -50,8 +51,13 @@ def text_gdoc(text: str) -> str:
|
|
| 50 |
|
| 51 |
def decode_base64(text: str):
|
| 52 |
if not text:
|
| 53 |
-
return
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
def render_audio(text, voice, rate, pitch):
|
| 57 |
sub_data = []
|
|
@@ -163,6 +169,10 @@ def add_karaoke_subtitles(subs, words):
|
|
| 163 |
|
| 164 |
def speech(text, voice, rate, pitch, webhook=None):
|
| 165 |
text = text.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
if not text:
|
| 167 |
raise ValueError("Please enter text")
|
| 168 |
if not voice:
|
|
|
|
| 7 |
import edge_tts
|
| 8 |
import pysubs2
|
| 9 |
import requests
|
| 10 |
+
import emoji
|
| 11 |
|
| 12 |
VOICES = ['en-US', 'ja-JP', 'ko-KR', 'zh-CN', 'vi-VN']
|
| 13 |
|
|
|
|
| 51 |
|
| 52 |
def decode_base64(text: str):
|
| 53 |
if not text:
|
| 54 |
+
return text
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
return base64.b64decode(text, validate=True).decode("utf-8")
|
| 58 |
+
except:
|
| 59 |
+
return text
|
| 60 |
+
|
| 61 |
|
| 62 |
def render_audio(text, voice, rate, pitch):
|
| 63 |
sub_data = []
|
|
|
|
| 169 |
|
| 170 |
def speech(text, voice, rate, pitch, webhook=None):
|
| 171 |
text = text.strip()
|
| 172 |
+
|
| 173 |
+
if text:
|
| 174 |
+
text = emoji.replace_emoji(text, replace='')
|
| 175 |
+
|
| 176 |
if not text:
|
| 177 |
raise ValueError("Please enter text")
|
| 178 |
if not voice:
|
requirements.txt
CHANGED
|
@@ -10,4 +10,5 @@ nanoid
|
|
| 10 |
gdown
|
| 11 |
cachetools
|
| 12 |
pysubs2
|
| 13 |
-
fire
|
|
|
|
|
|
| 10 |
gdown
|
| 11 |
cachetools
|
| 12 |
pysubs2
|
| 13 |
+
fire
|
| 14 |
+
emoji
|