mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 20:20:16 +09:00
do not save empty audio file
This commit is contained in:
parent
50e63109a3
commit
a4c9eaf6cd
@ -100,7 +100,7 @@ export function RealtimeChat({
|
||||
});
|
||||
}
|
||||
}
|
||||
await clientRef.current.generateResponse();
|
||||
// await clientRef.current.generateResponse();
|
||||
} catch (error) {
|
||||
console.error("Set message failed:", error);
|
||||
}
|
||||
@ -156,6 +156,7 @@ export function RealtimeChat({
|
||||
chatStore.updateTargetSession(session, (session) => {
|
||||
session.messages = session.messages.concat([botMessage]);
|
||||
});
|
||||
let hasAudio = false;
|
||||
for await (const content of item) {
|
||||
if (content.type === "text") {
|
||||
for await (const text of content.textChunks()) {
|
||||
@ -170,6 +171,7 @@ export function RealtimeChat({
|
||||
const audioTask = async () => {
|
||||
audioHandlerRef.current?.startStreamingPlayback();
|
||||
for await (const audio of content.audioChunks()) {
|
||||
hasAudio = true;
|
||||
audioHandlerRef.current?.playChunk(audio);
|
||||
}
|
||||
};
|
||||
@ -180,6 +182,7 @@ export function RealtimeChat({
|
||||
session.messages = session.messages.concat();
|
||||
});
|
||||
}
|
||||
if (hasAudio) {
|
||||
// upload audio get audio_url
|
||||
const blob = audioHandlerRef.current?.savePlayFile();
|
||||
uploadImage(blob!).then((audio_url) => {
|
||||
@ -191,6 +194,7 @@ export function RealtimeChat({
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleInputAudio = async (item: RTInputAudioItem) => {
|
||||
@ -275,7 +279,7 @@ export function RealtimeChat({
|
||||
const data = audioHandlerRef.current.getByteFrequencyData();
|
||||
console.log("getByteFrequencyData", data);
|
||||
}
|
||||
}, 100);
|
||||
}, 1000);
|
||||
|
||||
return () => {
|
||||
if (isRecording) {
|
||||
|
Loading…
Reference in New Issue
Block a user