mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🗣️ fix: Set Audio Run ID at Top of Autoplayback Request (#2926)
This commit is contained in:
parent
8318f26d66
commit
b8e35002f4
1 changed files with 5 additions and 4 deletions
|
|
@ -49,7 +49,8 @@ export default function StreamAudio({ index = 0 }) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const latestText = getLatestText(latestMessage);
|
const latestText = getLatestText(latestMessage);
|
||||||
const shouldFetch =
|
|
||||||
|
const shouldFetch = !!(
|
||||||
token &&
|
token &&
|
||||||
automaticPlayback &&
|
automaticPlayback &&
|
||||||
isSubmitting &&
|
isSubmitting &&
|
||||||
|
|
@ -60,7 +61,8 @@ export default function StreamAudio({ index = 0 }) {
|
||||||
!latestMessage.messageId.includes('_') &&
|
!latestMessage.messageId.includes('_') &&
|
||||||
!isFetching &&
|
!isFetching &&
|
||||||
activeRunId &&
|
activeRunId &&
|
||||||
activeRunId !== audioRunId;
|
activeRunId !== audioRunId
|
||||||
|
);
|
||||||
|
|
||||||
if (!shouldFetch) {
|
if (!shouldFetch) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -80,12 +82,12 @@ export default function StreamAudio({ index = 0 }) {
|
||||||
const cache = await caches.open('tts-responses');
|
const cache = await caches.open('tts-responses');
|
||||||
const cachedResponse = await cache.match(cacheKey);
|
const cachedResponse = await cache.match(cacheKey);
|
||||||
|
|
||||||
|
setAudioRunId(activeRunId);
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
console.log('Audio found in cache');
|
console.log('Audio found in cache');
|
||||||
const audioBlob = await cachedResponse.blob();
|
const audioBlob = await cachedResponse.blob();
|
||||||
const blobUrl = URL.createObjectURL(audioBlob);
|
const blobUrl = URL.createObjectURL(audioBlob);
|
||||||
setGlobalAudioURL(blobUrl);
|
setGlobalAudioURL(blobUrl);
|
||||||
setAudioRunId(activeRunId);
|
|
||||||
setIsFetching(false);
|
setIsFetching(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +115,6 @@ export default function StreamAudio({ index = 0 }) {
|
||||||
mediaSource = new MediaSourceAppender(type);
|
mediaSource = new MediaSourceAppender(type);
|
||||||
setGlobalAudioURL(mediaSource.mediaSourceUrl);
|
setGlobalAudioURL(mediaSource.mediaSourceUrl);
|
||||||
}
|
}
|
||||||
setAudioRunId(activeRunId);
|
|
||||||
|
|
||||||
let done = false;
|
let done = false;
|
||||||
const chunks: Uint8Array[] = [];
|
const chunks: Uint8Array[] = [];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue