refactor(engine): 修改虚拟环境设置,修改音频工具函数

- 更新虚拟环境目录名为 .venv
- 调整音频块采集速率默认值为 10
- 为 AudioStream 类添加重设音频块大小的方法
- 更新依赖文件 requirements.txt
This commit is contained in:
himeditator
2025-08-03 16:40:26 +08:00
parent 38b4b15cec
commit 1c0bf1f9c4
19 changed files with 99 additions and 70 deletions

View File

@@ -22,9 +22,9 @@ class AudioStream:
初始化参数:
audio_type: 0-系统音频输出流(需配合 BlackHole1-系统音频输入流
chunk_rate: 每秒采集音频块的数量,默认为20
chunk_rate: 每秒采集音频块的数量,默认为10
"""
def __init__(self, audio_type=0, chunk_rate=20):
def __init__(self, audio_type=0, chunk_rate=10):
self.audio_type = audio_type
self.mic = pyaudio.PyAudio()
if self.audio_type == 0:
@@ -40,6 +40,12 @@ class AudioStream:
self.RATE = int(self.device["defaultSampleRate"])
self.CHUNK = self.RATE // chunk_rate
def reset_chunk_size(self, chunk_size: int):
"""
重新设置音频块大小
"""
self.CHUNK = chunk_size
def get_info(self):
dev_info = f"""
采样设备:

View File

@@ -41,9 +41,9 @@ class AudioStream:
初始化参数:
audio_type: 0-系统音频输出流不支持不会生效1-系统音频输入流(默认)
chunk_rate: 每秒采集音频块的数量,默认为20
chunk_rate: 每秒采集音频块的数量,默认为10
"""
def __init__(self, audio_type=1, chunk_rate=20):
def __init__(self, audio_type=1, chunk_rate=10):
self.audio_type = audio_type
if self.audio_type == 0:
@@ -58,6 +58,12 @@ class AudioStream:
self.RATE = 48000
self.CHUNK = self.RATE // chunk_rate
def reset_chunk_size(self, chunk_size: int):
"""
重新设置音频块大小
"""
self.CHUNK = chunk_size
def get_info(self):
dev_info = f"""
音频捕获进程:

View File

@@ -46,9 +46,9 @@ class AudioStream:
初始化参数:
audio_type: 0-系统音频输出流默认1-系统音频输入流
chunk_rate: 每秒采集音频块的数量,默认为20
chunk_rate: 每秒采集音频块的数量,默认为10
"""
def __init__(self, audio_type=0, chunk_rate=20):
def __init__(self, audio_type=0, chunk_rate=10, chunk_size=-1):
self.audio_type = audio_type
self.mic = pyaudio.PyAudio()
if self.audio_type == 0:
@@ -64,6 +64,12 @@ class AudioStream:
self.RATE = int(self.device["defaultSampleRate"])
self.CHUNK = self.RATE // chunk_rate
def reset_chunk_size(self, chunk_size: int):
"""
重新设置音频块大小
"""
self.CHUNK = chunk_size
def get_info(self):
dev_info = f"""
采样设备: