Skip to content

fixed the text-to-speech (TTS) audio playback compatibility issue#31

Open
Prachi9306 wants to merge 1 commit intokaushav07:mainfrom
Prachi9306:main
Open

fixed the text-to-speech (TTS) audio playback compatibility issue#31
Prachi9306 wants to merge 1 commit intokaushav07:mainfrom
Prachi9306:main

Conversation

@Prachi9306
Copy link

Issue: Incompatibility of playsound with Python 3.13
The original implementation of text-to-speech (TTS) in VisionMate used the playsound library to play audio files generated by the Google Text-to-Speech (gTTS) engine. However, playsound is not compatible with Python 3.13, resulting in installation and runtime errors. This prevented users with the latest Python version from using the TTS feature.

How I Fixed the Issue-

  1. Removed the playsound Dependency
    You identified that playsound was causing compatibility issues.
    You removed playsound from both the codebase and the requirements.txt file, eliminating the source of the error.

  2. Switched to winsound and pydub for Audio Playback
    winsound is a built-in Python module on Windows that can play .wav files without external dependencies.
    pydub is a Python library that can convert audio files between formats (e.g., from .mp3 to .wav).
    Since gTTS generates .mp3 files and winsound only plays .wav files, you used pydub to convert the .mp3 output from gTTS to .wav.
    The updated workflow:
    Generate speech as an .mp3 file using gTTS.
    Convert the .mp3 file to .wav using pydub.
    Play the .wav file using winsound.
    Clean up temporary files after playback.

  3. Updated requirements.txt
    You removed playsound from the dependencies.
    You added pydub to ensure audio conversion works as expected.
    You included a note to install ffmpeg (required by pydub for audio conversion).

Benefits of My Fix

Python 3.13 Compatibility: The project now works with the latest Python version, making it accessible to more users.
Reliable TTS Playback: Audio playback is now robust and does not depend on third-party packages with compatibility issues.
Cleaner Dependency Management: The dependencies are up-to-date and relevant to the project’s needs.

@Prachi9306
Copy link
Author

Thank you for this amazing project! Please let me know if any changes are required. 😊

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.

1 participant