Skip to content

added text to speech feature #420

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LAbhilashKumar
Copy link

Added a text-to-speech feature using pyttsx3.
This feature allows the program to convert text into spoken voice output.
Closes #405
changes are welcome

Copy link
Owner

@DhanushNehru DhanushNehru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the correct format accordingly. Also update the main README.md section

@DhanushNehru DhanushNehru requested a review from Copilot July 21, 2025 15:24
Copilot

This comment was marked as outdated.

@DhanushNehru DhanushNehru requested a review from Copilot July 27, 2025 13:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a text-to-speech feature to the project using the pyttsx3 library. The implementation allows the program to convert text into spoken voice output using Microsoft's David voice engine.

  • Adds a new text-to-speech module with pyttsx3 integration
  • Configures speech rate and voice selection
  • Includes a demo implementation that speaks "hello world"
Comments suppressed due to low confidence (1)

text_to_speech.py:2

  • Variable name 'default_SpeechRate' should follow Python naming conventions and use lowercase with underscores: 'default_speech_rate'.
default_SpeechRate= 176

print(voice.name)

desired_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"
engine.setProperty(voice, desired_voice_id)
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument should be the string 'voice', not the variable 'voice' from the loop. This should be engine.setProperty('voice', desired_voice_id).

Suggested change
engine.setProperty(voice, desired_voice_id)
engine.setProperty("voice", desired_voice_id)

Copilot uses AI. Check for mistakes.

Comment on lines +9 to +10
desired_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"
engine.setProperty(voice, desired_voice_id)
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded Windows registry path makes this code platform-specific and non-portable. Consider using a cross-platform approach or making the voice selection configurable.

Suggested change
desired_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"
engine.setProperty(voice, desired_voice_id)
desired_voice_name = "David" # Replace with the desired voice name
selected_voice = None
for voice in voices:
if desired_voice_name.lower() in voice.name.lower():
selected_voice = voice.id
break
if selected_voice:
engine.setProperty("voice", selected_voice)
else:
print(f"Desired voice '{desired_voice_name}' not found. Using default voice.")
engine.setProperty("voice", voices[0].id)

Copilot uses AI. Check for mistakes.

Comment on lines +5 to +7
for voice in voices:
print(voice.id)
print(voice.name)
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The voice iteration loop prints all available voices but doesn't serve a clear purpose in the final implementation. Consider removing this debug code or making it conditional.

Suggested change
for voice in voices:
print(voice.id)
print(voice.name)
DEBUG_MODE = False # Set to True to enable debug output
if DEBUG_MODE:
for voice in voices:
print(voice.id)
print(voice.name)

Copilot uses AI. Check for mistakes.

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.

Add Voice Recognition and Audio Processing Script
3 participants