-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmain_cmd.py
More file actions
40 lines (32 loc) · 1.11 KB
/
main_cmd.py
File metadata and controls
40 lines (32 loc) · 1.11 KB
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
from src.audio_capture import LoopbackRecorder
from src.transcriber import SpeechTranscriber
from src.llm_client import LLMClient
import time
import os
def update_response(new_text):
#作为回调函数,更新response
print(new_text, end="", flush=True,sep="")
def main():
while True:
# 1. 录音
# 按ctrl+c开始
client = LLMClient()
input('按任意键开始录音...')
# 开始录音
print("正在启动录音...")
recorder = LoopbackRecorder(device_index=33)
recorder.start_recording("interview.wav")
recorder.record(duration=5)# 录制5秒
recorder.stop_recording()
print("录音完成")
# 2. 转写
print("\n开始转写...")
transcriber = SpeechTranscriber()
text = transcriber.transcribe("interview.wav")
print(f"\n转写内容: {text}")
# 3. LLM处理
print("\n模型回复:")
full_response = []
client.get_response(f"\n{text}", callback=update_response)
if __name__ == "__main__":
main()