Spaces:
Running
Running
ziqiangao
commited on
Commit
·
dc8a999
1
Parent(s):
7f8a1b2
update app.py
Browse files
app.py
CHANGED
@@ -160,10 +160,15 @@ def RenderVid(af, n, fps=30):
|
|
160 |
|
161 |
invisible_chars = ["\u200B", "\uFEFF"]
|
162 |
|
|
|
|
|
|
|
|
|
163 |
def stripinvisibles(s):
|
|
|
164 |
for i in invisible_chars:
|
165 |
-
|
166 |
-
return
|
167 |
|
168 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None):
|
169 |
p = gr.Progress()
|
@@ -175,7 +180,7 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, 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)
|
@@ -187,8 +192,9 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
187 |
haslyrics = True
|
188 |
else:
|
189 |
gr.Warning("Lyrics file is invalid, skipping")
|
190 |
-
except:
|
191 |
-
|
|
|
192 |
|
193 |
os.makedirs(path+f'out/{name}/', exist_ok=True)
|
194 |
global iii
|
|
|
160 |
|
161 |
invisible_chars = ["\u200B", "\uFEFF"]
|
162 |
|
163 |
+
def remove_bom(data: str) -> str:
|
164 |
+
BOM = '\ufeff'
|
165 |
+
return data.lstrip(BOM)
|
166 |
+
|
167 |
def stripinvisibles(s):
|
168 |
+
e = remove_bom(s)
|
169 |
for i in invisible_chars:
|
170 |
+
e.replace(i,"")
|
171 |
+
return e
|
172 |
|
173 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None):
|
174 |
p = gr.Progress()
|
|
|
180 |
try:
|
181 |
outf = open("out.srt",mode="x", encoding="UTF8")
|
182 |
sf = stripinvisibles(open(lyrics, encoding="UTF8").read())
|
183 |
+
print(sf[0])
|
184 |
if sf[0] == '[':
|
185 |
gr.Info("Lyrics of LRC type was detected, converting to SRT")
|
186 |
LRC2SRT.convert_to_srt(sf)
|
|
|
192 |
haslyrics = True
|
193 |
else:
|
194 |
gr.Warning("Lyrics file is invalid, skipping")
|
195 |
+
except Exception as e:
|
196 |
+
print(traceback.format_exc())
|
197 |
+
gr.Warning("Failed to parse lyrics, ensure there are no blank lines in between and invisible characters")
|
198 |
|
199 |
os.makedirs(path+f'out/{name}/', exist_ok=True)
|
200 |
global iii
|