Spaces:
Running
Running
ziqiangao
commited on
Commit
·
7f8a1b2
1
Parent(s):
ca1a3de
add character handling
Browse files
app.py
CHANGED
@@ -158,6 +158,13 @@ def RenderVid(af, n, fps=30):
|
|
158 |
)
|
159 |
gr.Interface.download(f"{n}.mp4")
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None):
|
162 |
p = gr.Progress()
|
163 |
if os.path.exists("out.srt"):
|
@@ -167,8 +174,8 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
167 |
p(0.5,"parsing lyrics")
|
168 |
try:
|
169 |
outf = open("out.srt",mode="x", encoding="UTF8")
|
170 |
-
|
171 |
-
sf
|
172 |
if sf[0] == '[':
|
173 |
gr.Info("Lyrics of LRC type was detected, converting to SRT")
|
174 |
LRC2SRT.convert_to_srt(sf)
|
|
|
158 |
)
|
159 |
gr.Interface.download(f"{n}.mp4")
|
160 |
|
161 |
+
invisible_chars = ["\u200B", "\uFEFF"]
|
162 |
+
|
163 |
+
def stripinvisibles(s):
|
164 |
+
for i in invisible_chars:
|
165 |
+
s.replace(i,"")
|
166 |
+
return s
|
167 |
+
|
168 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None):
|
169 |
p = gr.Progress()
|
170 |
if os.path.exists("out.srt"):
|
|
|
174 |
p(0.5,"parsing lyrics")
|
175 |
try:
|
176 |
outf = open("out.srt",mode="x", encoding="UTF8")
|
177 |
+
sf = stripinvisibles(open(lyrics, encoding="UTF8").read())
|
178 |
+
print(sf)
|
179 |
if sf[0] == '[':
|
180 |
gr.Info("Lyrics of LRC type was detected, converting to SRT")
|
181 |
LRC2SRT.convert_to_srt(sf)
|