mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +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 (
|
||||
playbackRate &&
|
||||
globalAudioURL &&
|
||||
playbackRate > 0 &&
|
||||
audioRef.current &&
|
||||
audioRef.current.playbackRate !== playbackRate
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,12 @@ export default function MessageAudio({ index, message, isLast }: THoverButtons)
|
|||
if (!messageAudio) {
|
||||
return;
|
||||
}
|
||||
if (playbackRate && messageAudio && messageAudio.playbackRate !== playbackRate) {
|
||||
if (
|
||||
playbackRate &&
|
||||
playbackRate > 0 &&
|
||||
messageAudio &&
|
||||
messageAudio.playbackRate !== playbackRate
|
||||
) {
|
||||
messageAudio.playbackRate = playbackRate;
|
||||
}
|
||||
}, [audioRef, isSpeaking, playbackRate, message.messageId]);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default function DecibelSelector() {
|
|||
value={[playbackRate ?? 1]}
|
||||
onValueChange={(value) => setPlaybackRate(value[0])}
|
||||
doubleClickHandler={() => setPlaybackRate(null)}
|
||||
min={-0.1}
|
||||
min={0.1}
|
||||
max={2}
|
||||
step={0.1}
|
||||
className="ml-4 flex h-4 w-24"
|
||||
|
|
@ -33,7 +33,7 @@ export default function DecibelSelector() {
|
|||
value={playbackRate ?? 1}
|
||||
disabled={!textToSpeech}
|
||||
onChange={(value) => setPlaybackRate(value ? value[0] : 0)}
|
||||
min={-0.1}
|
||||
min={0.1}
|
||||
max={2}
|
||||
className={cn(
|
||||
defaultTextProps,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function useTextToSpeechExternal(messageId: string, isLast: boolean, index = 0)
|
|||
const playAudioPromise = (blobUrl: string) => {
|
||||
const newAudio = new Audio(blobUrl);
|
||||
const initializeAudio = () => {
|
||||
if (playbackRate && playbackRate !== 1) {
|
||||
if (playbackRate && playbackRate !== 1 && playbackRate > 0) {
|
||||
newAudio.playbackRate = playbackRate;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue