-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
77 lines (58 loc) · 1.73 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import logging.config
import redis
import config
from log_config import logging_dict_config
from recognizer import SpeechRecognizer
from task import ASRTask
logging.config.dictConfig(logging_dict_config)
logger = logging.getLogger()
urls = [
# "http://1258455058.vod2.myqcloud.com/1def07cdvodcq1258455058/e546c45c243791579844613923/f0.aac",
"http://1258455058.vod2.myqcloud.com/1def07cdvodcq1258455058/9ad6ba91243791579843741011/f0.aac",
# "http://1258455058.vod2.myqcloud.com/1def07cdvodcq1258455058/dbac6b65243791579861837907/f0.aac",
# "http://1258455058.vod2.myqcloud.com/1def07cdvodcq1258455058/7da29bdb243791579853326813/f0.aac",
# "http://1258455058.vod2.myqcloud.com/1def07cdvodcq1258455058/cb79a958243791579861152364/f0.aac",
]
infos = [
{
"size": 0,
"duration": 0,
"url": url,
"start_time": "",
"end_time": ""
} for url in urls
]
def get_audio_info():
"""
info = {
"size": 0,
"duration": 0,
"url": "",
"start_time": "",
"end_time": ""
}
"""
if len(infos) > 0:
info = infos.pop()
else:
info = None
return info
cli = redis.Redis(host=config.REDIS_HOST, port=config.REDIS_PORT, decode_responses=True)
def get_audio_info():
url = cli.rpop(config.ASR_AUDIO_URL_LIST)
if url:
return {"url": url}
return None
def run():
rec = SpeechRecognizer(model_name="large")
while True:
# 第一步,获取url
info = get_audio_info()
if not info:
logger.info("info is none")
break
# 第二步,创建任务,并执行
task = ASRTask(info, recognizer=rec)
task.run()
if __name__ == "__main__":
run()