tibOin / macos_speech

Ever wanted to leverage the macOS builtin speech synthesis directly into python ? Or just make your code talk...
MIT License
3 stars 0 forks source link

cut off beginning #3

Open Michael-Rempel opened 6 months ago

Michael-Rempel commented 6 months ago

on multi-line speech the first part of the commanded speech is cut off. Default voice on Mac M2 / Python 3.8.19

tibOin commented 6 months ago

Hey, just tried a simple multi-line text on MacBook Air M2 / Python 3.11.0 and it works normally.

Could you send an example code that reproduce the problem?

Michael-Rempel commented 6 months ago

Eddy is one of the better voices. It seems the speaker talk isn’t waiting for the driver to finish initialization. Opening speak is cut off or missing all together. I stuck it in to make sure saying I was long enough into the text to not be the problem, and it always works from that point onward now.I tried the Siri voice as suggested, and it works quite well, but also suffers from cut off at the start.

For some voices say hello doesn’t fire at all

And finally, the words ‘quotation mark’ get said at the end of the triple.

from macos_speech import Synthesizer

speaker = Synthesizer() speaker.voice = 'Eddy' speaker.text = """ opening speak I can make my python code to talk! And I can even send multiple lines! Awesome. """

speaker.talk()

or

speaker.say("Hello!")

On May 28, 2024, at 6:07 AM, Anon @.***> wrote:

Hey, just tried a simple multi-line text on MacBook Air M2 / Python 3.11.0 and it works normally.

Could you send an example code that reproduce the problem?

— Reply to this email directly, view it on GitHub https://github.com/tibOin/macos_speech/issues/3#issuecomment-2135174651, or unsubscribe https://github.com/notifications/unsubscribe-auth/BE3ITC2QRXM3I4NONCJWLO3ZER6QPAVCNFSM6AAAAABIL7LLIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGE3TINRVGE. You are receiving this because you authored the thread.

tibOin commented 6 months ago

Well, just tried with eddy too and no noticeable problem here. I also noticed that "quotation mark" is sometime said, but I don't really understand why. With the code you gave it doesn't say it.

That said, this library relies on the say command that's present on every macOS since the very first Macintosh. There might be changes from one version of macOS to another...

I recommand you to try to write your text in a file, then in your terminal type the following command : cat yourtextfile.anything | say -v Eddy

Does it cut off too? If it's the case (and it should be) it's a problem with the say command on your system.

As a potential mitigation, maybe try to add some delay at the start of your text by inserting [100] (or any number of milliseconds that resolve your problem). It would be a workaround, but by now, it's the only idea I got. I will do some research.

tibOin commented 6 months ago

I found this on stackoverflow : One possible reason for cutoff

And this post says that there are bugs in speech on macOS Ventura. So I also encourage to update your OS if it's not already up to date.

Michael-Rempel commented 6 months ago

I am on Sonoma 14.5 I will look at those articles. Thanks for digging a bit. I will update you if I find anything new to report.

Michael

On May 28, 2024, at 2:02 PM, Anon @.***> wrote:

I found this on stackoverflow : One possible reason for cutoff https://apple.stackexchange.com/questions/425755/how-to-avoid-audio-clipping-when-using-say-command-in-applescript And this article https://www.applevis.com/forum/macos-mac-apps/voice-over-speech-output-frequently-interrupted-macos-135 says that there are bugs in speech on macOS Ventura. So I also encourage to update your OS if it's not already up to date.

— Reply to this email directly, view it on GitHub https://github.com/tibOin/macos_speech/issues/3#issuecomment-2136098368, or unsubscribe https://github.com/notifications/unsubscribe-auth/BE3ITCY3EKS6GPJCCJS7M3DZETWG3AVCNFSM6AAAAABIL7LLIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZWGA4TQMZWHA. You are receiving this because you authored the thread.

tibOin commented 6 months ago

That's strange. I'm on Sonoma too and it works pretty well. Maybe also check for Siri and VoiceOver in the system's settings.
According to what I shared earlier, 3rd party tools could also be responsible.

And yes, I'd be curious of anything you find. (And if someone else sees this discussion...)

Thanks a lot for your interest and your feedback