Issue
I am looking for a way to play any sound after finishing my code. I have tried many ways to do it.
For example:
os.system('say "your program has finished"')
sys.stdout.write('\a')
sys.stdout.flush()
winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
print ("\a")
But neither of them are working in conda (ipython notebook)
Do you know any way to do it in conda, any sound Ideal will be not using music file, using something from system sounds, but it doesn't matter. What does matter is fast execution.
I am using Python 3 on windows 10.
Thanks
Solution
There is a speech
library in conda which can solve your query as well as provide extra set of features:
First you need to install the package:
pip install -i https://pypi.anaconda.org/pypi/simple speech
After that simply try:
import speech
speech.say('Completed coding', 'es_ES')
On windows 10, it has a speech engine included.
Install the module win32com
, then you can use this code:
import win32com.client as wincl
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("Finished coding")
For more information check out: https://anaconda.org/pypi/speech
Hope it helps....Happy coding
Answered By - user7571182
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.