Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎙️ fix: Optimize and Fix Browser TTS Incompatibility (firefox) #3627

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

danny-avila
Copy link
Owner

@danny-avila danny-avila commented Aug 13, 2024

Summary

Addresses TTS issues with MSEDGE voices on firefox

  • Refactored the HoverButtons and MessageAudio components to only pass necessary props, reducing unnecessary re-renders and improving performance.
  • Updated the useTextToSpeech hook to accept an object of props instead of individual parameters
  • Enhanced the MessageAudio component to handle null or undefined values more gracefully (type safety)
  • Optimized the useEffect hook in MessageAudio to only run when necessary dependencies change.
  • Updated the useTextToSpeechEdge hook to handle browser compatibility issues, specifically for browsers that don't support 'audio/mpeg' (e.g., Firefox).
  • Implemented a check for browser support of 'audio/mpeg' in useTextToSpeechEdge, returning a dummy object with empty functions when not supported.
  • Added conditional rendering in useTextToSpeechEdge to prevent unnecessary initialization on unsupported browsers.

Testing

To test these changes:

  1. Test the TTS functionality on different browsers, especially Chrome and Firefox.
  2. Verify that the TTS buttons appear and function correctly in the chat interface.
  3. Check that the audio playback works as expected on supported browsers.
  4. Ensure that the application doesn't throw errors or break on unsupported browsers.

Test Configuration:

  • Test on latest versions of Chrome, Firefox, and Edge browsers
  • Test with different types of messages (text-only, code blocks, etc.)
  • Verify functionality with different TTS voices and settings

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • I have tested my changes in multiple browsers to ensure cross-browser compatibility

@danny-avila danny-avila merged commit e3ebcfd into main Aug 13, 2024
3 checks passed
@danny-avila danny-avila deleted the fix/firefox-audio-errors branch August 13, 2024 08:14
@rio2dev
Copy link

rio2dev commented Aug 13, 2024

Thanks! I tested Safari on iPhone. MediaSource brokes whole app when opening Settings -> Speech tab.
Safari on iPhone does not have MediaSource.
https://developer.mozilla.org/en-US/docs/Web/API/MediaSource#browser_compatibility

@danny-avila
Copy link
Owner Author

Thanks! I tested Safari on iPhone. MediaSource brokes whole app when opening Settings -> Speech tab.
Safari on iPhone does not have MediaSource.
https://developer.mozilla.org/en-US/docs/Web/API/MediaSource#browser_compatibility

Thanks will look into it

@danny-avila
Copy link
Owner Author

Thanks! I tested Safari on iPhone. MediaSource brokes whole app when opening Settings -> Speech tab. Safari on iPhone does not have MediaSource. https://developer.mozilla.org/en-US/docs/Web/API/MediaSource#browser_compatibility

Resolved here #3632

danny-avila added a commit that referenced this pull request Aug 17, 2024
* fix: 'disable' MsEdgeTTS on unsupported browser (firefox)

* refactor: only pass necessary props to HoverButton MessageAudio

* refactor: Fix conditional comparison operators in MessageAudio component

* refactor: Remove console.log statement in MessageAudio component
kenshinsamue pushed a commit to intelequia/LibreChat that referenced this pull request Sep 17, 2024
…-avila#3627)

* fix: 'disable' MsEdgeTTS on unsupported browser (firefox)

* refactor: only pass necessary props to HoverButton MessageAudio

* refactor: Fix conditional comparison operators in MessageAudio component

* refactor: Remove console.log statement in MessageAudio component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants