mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-19 09:46:38 +08:00
feat: 添加音频上下文管理,优化 PCM 数据转换为 AudioBuffer 的实现
This commit is contained in:
parent
221229ce2f
commit
fe484fd38a
@ -64,6 +64,7 @@ interface RequestPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class QwenApi implements LLMApi {
|
export class QwenApi implements LLMApi {
|
||||||
|
private audioContext?: AudioContext;
|
||||||
path(path: string): string {
|
path(path: string): string {
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
|
|
||||||
@ -363,8 +364,11 @@ export class QwenApi implements LLMApi {
|
|||||||
|
|
||||||
// 将 PCM 字节数据转换为 AudioBuffer
|
// 将 PCM 字节数据转换为 AudioBuffer
|
||||||
private convertToAudioBuffer(pcmData: Uint8Array) {
|
private convertToAudioBuffer(pcmData: Uint8Array) {
|
||||||
const audioContext = new (window.AudioContext ||
|
if (!this.audioContext) {
|
||||||
window.webkitAudioContext)();
|
this.audioContext = new (window.AudioContext ||
|
||||||
|
window.webkitAudioContext)();
|
||||||
|
}
|
||||||
|
const audioContext = this.audioContext;
|
||||||
const channels = 1;
|
const channels = 1;
|
||||||
const sampleRate = 24000;
|
const sampleRate = 24000;
|
||||||
return new Promise<AudioBuffer>((resolve, reject) => {
|
return new Promise<AudioBuffer>((resolve, reject) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user