mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
feat: 优化了语音配置页面的效果;新增语音实际波形图显示;新增语音点击跳转进度
fix: 修复了一个可能导致语音解密错乱的问题
This commit is contained in:
@@ -2202,7 +2202,7 @@ class ChatService {
|
||||
|
||||
|
||||
// 3. 调用 C++ 接口获取语音 (Hex)
|
||||
const voiceRes = await wcdbService.getVoiceData(sessionId, msgCreateTime, candidates, msgSvrId)
|
||||
const voiceRes = await wcdbService.getVoiceData(sessionId, msgCreateTime, candidates, localId, msgSvrId)
|
||||
if (!voiceRes.success || !voiceRes.hex) {
|
||||
return { success: false, error: voiceRes.error || '未找到语音数据' }
|
||||
}
|
||||
@@ -2245,6 +2245,33 @@ class ChatService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查语音是否已有缓存
|
||||
*/
|
||||
async resolveVoiceCache(sessionId: string, msgId: string): Promise<{ success: boolean; hasCache: boolean; data?: string }> {
|
||||
try {
|
||||
const cacheKey = this.getVoiceCacheKey(sessionId, msgId)
|
||||
|
||||
// 1. 检查内存缓存
|
||||
const inMemory = this.voiceWavCache.get(cacheKey)
|
||||
if (inMemory) {
|
||||
return { success: true, hasCache: true, data: inMemory.toString('base64') }
|
||||
}
|
||||
|
||||
// 2. 检查文件缓存
|
||||
const cachedFile = this.getVoiceCacheFilePath(cacheKey)
|
||||
if (existsSync(cachedFile)) {
|
||||
const wavData = readFileSync(cachedFile)
|
||||
this.cacheVoiceWav(cacheKey, wavData) // 回甜内存
|
||||
return { success: true, hasCache: true, data: wavData.toString('base64') }
|
||||
}
|
||||
|
||||
return { success: true, hasCache: false }
|
||||
} catch (e) {
|
||||
return { success: false, hasCache: false }
|
||||
}
|
||||
}
|
||||
|
||||
async getVoiceData_Legacy(sessionId: string, msgId: string): Promise<{ success: boolean; data?: string; error?: string }> {
|
||||
try {
|
||||
const localId = parseInt(msgId, 10)
|
||||
|
||||
Reference in New Issue
Block a user