Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Week 1/3-1.zip
Binary file not shown.
37 changes: 37 additions & 0 deletions Week 1/Task3-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Import necessary libraries
# %pip install pyttsx3

import pyttsx3

# Function to generate a voice response based on characteristics
def generate_voice_response(prompt):
# Initialize the text-to-speech engine
engine = pyttsx3.init()

# Set properties for the voice
engine.setProperty('rate', 150) # Slow pace
engine.setProperty('volume', 1) # Volume (0.0 to 1.0)

# Get available voices and set a friendly voice (if available)
voices = engine.getProperty('voices')
for voice in voices:
if 'english' in voice.languages:
engine.setProperty('voice', voice.id)
break

# Speak the response based on the prompt
response = f"You described the voice as: {prompt}"
engine.say(response)
engine.runAndWait()

# Main function to run the system
def main():
# Capture the descriptive text prompt from the user
# prompt = "warm and soothing, with a medium pitch, slow pace, and a friendly tone."
prompt = "A female senior with a guttural voice and an American accent. Their voice should be hoarse and have a boisterous intensity."

generate_voice_response(prompt)

# Run the main function
if __name__ == "__main__":
main()