紧急更新

1、删除意外出的语音合成开关;
2、唤醒、麦克风、扬声器可以启动后开启和关闭。
This commit is contained in:
guo zebin 2024-11-01 09:18:19 +08:00
parent c31193e28f
commit 10d419e1e6
5 changed files with 28 additions and 25 deletions

View File

@ -315,16 +315,15 @@ class FeiFei:
def say(self, interact, text):
try:
result = None
if config_util.config["interact"]["sound_synthesis_enabled"]:
audio_url = interact.data.get('audio')#透传的音频
if audio_url is not None:
file_name = 'sample-' + str(int(time.time() * 1000)) + '.wav'
result = self.download_wav(audio_url, './samples/', file_name)
elif config_util.config["interact"]["playSound"] or wsa_server.get_instance().is_connected(interact.data.get("user")) or self.__is_send_remote_device_audio(interact):#tts
util.printInfo(1, interact.data.get('user'), '合成音频...')
tm = time.time()
result = self.sp.to_sample(text.replace("*", ""), self.__get_mood_voice())
util.printInfo(1, interact.data.get('user'), '合成音频完成. 耗时: {} ms 文件:{}'.format(math.floor((time.time() - tm) * 1000), result))
audio_url = interact.data.get('audio')#透传的音频
if audio_url is not None:
file_name = 'sample-' + str(int(time.time() * 1000)) + '.wav'
result = self.download_wav(audio_url, './samples/', file_name)
elif config_util.config["interact"]["playSound"] or wsa_server.get_instance().is_connected(interact.data.get("user")) or self.__is_send_remote_device_audio(interact):#tts
util.printInfo(1, interact.data.get('user'), '合成音频...')
tm = time.time()
result = self.sp.to_sample(text.replace("*", ""), self.__get_mood_voice())
util.printInfo(1, interact.data.get('user'), '合成音频完成. 耗时: {} ms 文件:{}'.format(math.floor((time.time() - tm) * 1000), result))
if result is not None:
MyThread(target=self.__process_output_audio, args=[result, interact, text]).start()

View File

@ -201,6 +201,10 @@ class Recorder:
audio_data_list = []
while self.__running:
try:
record = cfg.config['source']['record']
if not record['enabled']:
time.sleep(0.1)
continue
self.is_reading = True
data = stream.read(1024, exception_on_overflow=False)
self.is_reading = False

View File

@ -48,6 +48,13 @@ class RecorderListener(Recorder):
def get_stream(self):
try:
#是否录音的控制是放在recorder.py的这里的作用是防止没有麦克风的设备出错
while True:
record = config_util.config['source']['record']
if record['enabled']:
break
time.sleep(0.1)
self.paudio = pyaudio.PyAudio()
device_id = 0 # 或者根据需要选择其他设备
@ -221,7 +228,7 @@ def kill_process_by_port(port):
except(psutil.NosuchProcess, psutil.AccessDenied):
pass
#数字人端请求获取最新的自动播放消息,若自动播放服务关闭会自动退出自动播放
def start_auto_play_service():
def start_auto_play_service(): #TODO 评估一下有无优化的空间
url = f"{config_util.config['source']['automatic_player_url']}/get_auto_play_item"
user = "User" #TODO 临时固死了
is_auto_server_error = False
@ -364,8 +371,8 @@ def start():
record = config_util.config['source']['record']
if record['enabled']:
util.log(1, '开启录音服务...')
recorderListener = RecorderListener(record['device'], feiFei) # 监听麦克风
recorderListener.start()
recorderListener = RecorderListener(record['device'], feiFei) # 监听麦克风
recorderListener.start()
#启动声音沟通接口服务
util.log(1,'启动声音沟通接口服务...')

View File

@ -137,7 +137,6 @@ new Vue({
visualization_detection_enabled: false,
source_record_enabled: false,
source_record_device: '',
sound_synthesis_enabled: true,
attribute_name: "",
attribute_gender: "",
attribute_age: "",
@ -211,7 +210,6 @@ new Vue({
if (config.interact) {
this.play_sound_enabled = config.interact.playSound;
this.visualization_detection_enabled = config.interact.visualization;
this.sound_synthesis_enabled = config.interact.sound_synthesis_enabled;
this.QnA = config.interact.QnA;
}
if (config.source && config.source.record) {
@ -277,7 +275,6 @@ new Vue({
},
"interact": {
"playSound": this.play_sound_enabled,
"sound_synthesis_enabled": this.sound_synthesis_enabled,
"visualization": this.visualization_detection_enabled,
"QnA": this.QnA,
"maxInteractTime": this.interact_maxInteractTime,

View File

@ -55,7 +55,7 @@
<div class="setting_wakeup">
<ul>
<li> <span class="font_name">唤醒模式:</span>
<el-switch :disabled="!configEditable"
<el-switch @change=saveConfig()
v-model="wake_word_enabled"
active-color="#13ce66"
inactive-color="#ff4949">
@ -74,12 +74,12 @@
<div class="microphone">
<div class="microphone_group1">
<span class="font_name">&nbsp;&nbsp;&nbsp;:</span>
<el-switch v-model="play_sound_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
<span class="font_name">服务器扬声器</span>
<el-switch v-model="play_sound_enabled" active-color="#13ce66" inactive-color="#ff4949" @change=saveConfig()> </el-switch>
</div>
<div class="microphone_group1" >
<span class="font_name">&nbsp;&nbsp;&nbsp;&nbsp;:</span>
<el-switch v-model="source_record_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
<span class="font_name">服务器麦克风</span>
<el-switch v-model="source_record_enabled" active-color="#13ce66" inactive-color="#ff4949" @change=saveConfig()> </el-switch>
</div>
</div>
<div class="setting_wakeup">
@ -90,10 +90,6 @@
:label="item.label" :value="item.value">
</option>
</select></li>
<li>
<span class="font_name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</span>
<el-switch v-model="sound_synthesis_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
</li>
<li style="display: flex;"> <span class="font_name" style="line-height: 36px;">&nbsp;&nbsp;&nbsp;&nbsp;:</span>
<el-slider style="width: 230px;" v-model="interact_perception_follow" :disabled="!configEditable"></el-slider></li>
</ul>