1

I want to code a script for example

If 'song' in command: Playsound(path) Speak(path)

It should work like. When speech recognition is imported and when i run script, it starts listening and when i say a trigger word the audio of given path startsplaying

1 Answers1

0

I'd recommend the python module pyttsx3 for text to speech. You can just pass a string through to the engine and will use a voice (which you can change) to speak it out in one of those robotic voices.

For example:

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

If you are looking merely for being able to run .wav, .mpf, or other sound files such as songs I'd recommend checking out the playsound module

Here's an example of that below:

from playsound import playsound
playsound('audio.mp3')