Skip to content

Commit cef8b6e

Browse files
committed
fix: api cache
1 parent 70bf4df commit cef8b6e

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

lib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION=1
2-
version_str="v0.0.1"
1+
VERSION=2
2+
version_str="v0.0.2"

lib/cfg.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ def parse_ini():
1313
t = line.strip()
1414
if t and not t.startswith(';') and t.find('=') > 0:
1515
t = t.split('=', maxsplit=1)
16-
sets[t[0]] = t[1]
16+
if t[1]=='false':
17+
sets[t[0]]=False
18+
elif t[1]=='true':
19+
sets[t[0]]=True
20+
else:
21+
sets[t[0]] = t[1] if t[1] else ""
1722

1823
return sets
1924

set.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
;绑定ip和端口, 127.0.0.1 代表本机,9933为端口
2-
web_address=127.0.0.1:9933
2+
web_address=127.0.0.1:9933
3+
only_local=false

start.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from flask import Flask, request, render_template, jsonify, send_from_directory
33
import os
44
import logging
5+
import time
56
from logging.handlers import RotatingFileHandler
67
import warnings
78

@@ -58,7 +59,7 @@ def api():
5859
noextname, ext = os.path.splitext(audio_file.filename)
5960
ext = ext.lower()
6061
# 如果是视频,先分离
61-
wav_file = os.path.join(cfg.TMP_DIR, f'{noextname}.wav')
62+
wav_file = os.path.join(cfg.TMP_DIR, f'{time.time()}.wav')
6263
print(f'{wav_file=}')
6364
if not os.path.exists(wav_file) or os.path.getsize(wav_file) == 0:
6465
if ext in ['.mp4', '.mov', '.avi', '.mkv', '.mpeg', '.mp3', '.flac']:
@@ -78,17 +79,18 @@ def api():
7879
audio_file.save(wav_file)
7980
else:
8081
return jsonify({"code": 1, "msg": f"不支持的格式 {ext}"})
81-
print(f'{ext=}')
82+
#print(f'{ext=}')
8283
sets = cfg.parse_ini()
8384
model = AutoModel(model="paraformer-zh", model_revision="v2.0.4",
8485
vad_model="fsmn-vad", vad_model_revision="v2.0.4",
8586
punc_model="ct-punc-c", punc_model_revision="v2.0.4",
87+
local_files_only=cfg.sets.get('only_local',False)
8688
)
8789
res = model.generate(input=wav_file, return_raw_text=True, is_final=True,
8890
sentence_timestamp=True, batch_size_s=100)
8991
raw_subtitles = []
9092
for it in res[0]['sentence_info']:
91-
print(it)
93+
#print(it)
9294
raw_subtitles.append({
9395
"line": len(raw_subtitles) + 1,
9496
"text": it['text'],

static/layui.zip

364 KB
Binary file not shown.

0 commit comments

Comments
 (0)