mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔈 fix(tts): update min value for playback rate (#2880)
* 🔈 fix: update min value for playback rate in TTS component
* fix: prevent playbackRate from being set if less than or equal to 0
This commit is contained in:
parent
b80f38e49e
commit
eb5733083e
4 changed files with 10 additions and 4 deletions
|
|
@ -193,6 +193,7 @@ export default function StreamAudio({ index = 0 }) {
|
||||||
if (
|
if (
|
||||||
playbackRate &&
|
playbackRate &&
|
||||||
globalAudioURL &&
|
globalAudioURL &&
|
||||||
|
playbackRate > 0 &&
|
||||||
audioRef.current &&
|
audioRef.current &&
|
||||||
audioRef.current.playbackRate !== playbackRate
|
audioRef.current.playbackRate !== playbackRate
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,12 @@ export default function MessageAudio({ index, message, isLast }: THoverButtons)
|
||||||
if (!messageAudio) {
|
if (!messageAudio) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playbackRate && messageAudio && messageAudio.playbackRate !== playbackRate) {
|
if (
|
||||||
|
playbackRate &&
|
||||||
|
playbackRate > 0 &&
|
||||||
|
messageAudio &&
|
||||||
|
messageAudio.playbackRate !== playbackRate
|
||||||
|
) {
|
||||||
messageAudio.playbackRate = playbackRate;
|
messageAudio.playbackRate = playbackRate;
|
||||||
}
|
}
|
||||||
}, [audioRef, isSpeaking, playbackRate, message.messageId]);
|
}, [audioRef, isSpeaking, playbackRate, message.messageId]);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export default function DecibelSelector() {
|
||||||
value={[playbackRate ?? 1]}
|
value={[playbackRate ?? 1]}
|
||||||
onValueChange={(value) => setPlaybackRate(value[0])}
|
onValueChange={(value) => setPlaybackRate(value[0])}
|
||||||
doubleClickHandler={() => setPlaybackRate(null)}
|
doubleClickHandler={() => setPlaybackRate(null)}
|
||||||
min={-0.1}
|
min={0.1}
|
||||||
max={2}
|
max={2}
|
||||||
step={0.1}
|
step={0.1}
|
||||||
className="ml-4 flex h-4 w-24"
|
className="ml-4 flex h-4 w-24"
|
||||||
|
|
@ -33,7 +33,7 @@ export default function DecibelSelector() {
|
||||||
value={playbackRate ?? 1}
|
value={playbackRate ?? 1}
|
||||||
disabled={!textToSpeech}
|
disabled={!textToSpeech}
|
||||||
onChange={(value) => setPlaybackRate(value ? value[0] : 0)}
|
onChange={(value) => setPlaybackRate(value ? value[0] : 0)}
|
||||||
min={-0.1}
|
min={0.1}
|
||||||
max={2}
|
max={2}
|
||||||
className={cn(
|
className={cn(
|
||||||
defaultTextProps,
|
defaultTextProps,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ function useTextToSpeechExternal(messageId: string, isLast: boolean, index = 0)
|
||||||
const playAudioPromise = (blobUrl: string) => {
|
const playAudioPromise = (blobUrl: string) => {
|
||||||
const newAudio = new Audio(blobUrl);
|
const newAudio = new Audio(blobUrl);
|
||||||
const initializeAudio = () => {
|
const initializeAudio = () => {
|
||||||
if (playbackRate && playbackRate !== 1) {
|
if (playbackRate && playbackRate !== 1 && playbackRate > 0) {
|
||||||
newAudio.playbackRate = playbackRate;
|
newAudio.playbackRate = playbackRate;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue