AVFAudio.AVSpeechSynthesizer Help
<[email protected]> Sat, 19 Feb 2022 18:30:24 -0800
| Newsgroups | gmane.comp.python.apple |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
--===============1767159106316866520==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0608_01D825BE.C3931580"
Content-Language: en-us
This is a multipart message in MIME format.
------=_NextPart_000_0608_01D825BE.C3931580
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi all,
I am new to the list. I am looking for some help relating to one of the Mac
standard libraries that python has bindings for. I need help with the
AVSpeechSynthesizer object found in the AVFAudio library. I am working on an
open source project called accessible_output2, and have been trying to find
a good solution for interfacing with the currently running instance of the
built in screen reader Voiceover. Specifically, I am looking to send text to
a function, and get speech output from Voiceover using the users existing
settings if any. This is a library to help provide screen reader output for
people who are blind or visually impaired. I already am using
NSSpeechSynthesizer to provide default speech output, so if voiceover is not
loaded, NSSpeechSynthesizer is used to provide speech using default
voiceover settings. However, I would really like to find a way to either
communicate directly with the running instance of Voiceover if any, or to
use the users voiceover settings to configure the synthesizer object.
I have done a lot of research on this, and think that AVSpeechSynthesizer is
what I want, however it does not seem to be working as expected. There is a
property in the AVSpeechUtterance classs, which is passed into the
AVSpeechSynthesizer.speakUtterance method, called
prefersAssistiveTechnologySettings. This setting, based on the
documentation, is supposed to pull the users existing Voiceover settings,
rate, pitch, voice, etc., and use these to configure the utterance object.
However, when I run the below code, all I get is Voiceover speaking with the
default settings. No matter what I do, it seems that AVSpeechUtterance just
is not picking up my custom user settings for Voiceover. To clarify, I have
definitely changed the Voiceover default settings.
from AVFoundation import AVSpeechSynthesizer
from AVFoundation import AVSpeechUtterance
voiceover = AVSpeechSynthesizer.alloc().init()
utterance = AVSpeechUtterance.speechUtteranceWithString_("hello world")
utterance.setPrefersAssistiveTechnologySettings_(True)
voiceover.speakUtterance_(utterance)
input()
Unfortunately, I do not know swift or ObjectiveC. I have been looking into
them, and am trying to put together a test of this code in either language,
but not having much luck yet.
Since this code runs, I really only have two guesses; either the property is
not correctly configured in the python bindings, or I am wondering if I need
to specify the Boolean differently here to work with the underlying
ObjectiveC framework. Does anyone have an idea on what to do next? If this
is not the correct place to ask, can someone point me in the right direction
of where I can talk to someone who might know more about this?
Here is the AVSpeechSynthesizer documentation:
https://developer.apple.com/documentation/avfaudio/avspeechsynthesizer?langu
age=objc
Thanks,
Timothy Breitenfeldt
------=_NextPart_000_0608_01D825BE.C3931580
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 15 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US =
link=3D"#0563C1" vlink=3D"#954F72" style=3D'word-wrap:break-word'><div =
class=3DWordSection1><p class=3DMsoNormal>Hi all,<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>I am new to =
the list. I am looking for some help relating to one of the Mac standard =
libraries that python has bindings for. I need help with the =
AVSpeechSynthesizer object found in the AVFAudio library. I am working =
on an open source project called accessible_output2, and have been =
trying to find a good solution for interfacing with the currently =
running instance of the built in screen reader Voiceover. Specifically, =
I am looking to send text to a function, and get speech output from =
Voiceover using the users existing settings if any. This is a library to =
help provide screen reader output for people who are blind or visually =
impaired. I already am using NSSpeechSynthesizer to provide default =
speech output, so if voiceover is not loaded, NSSpeechSynthesizer is =
used to provide speech using default voiceover settings. However, I =
would really like to find a way to either communicate directly with the =
running instance of Voiceover if any, or to use the users voiceover =
settings to configure the synthesizer object.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>I have done =
a lot of research on this, and think that AVSpeechSynthesizer is what I =
want, however it does not seem to be working as expected. There is a =
property in the AVSpeechUtterance classs, which is passed into the =
AVSpeechSynthesizer.speakUtterance method, called =
prefersAssistiveTechnologySettings. This setting, based on the =
documentation, is supposed to pull the users existing Voiceover =
settings, rate, pitch, voice, etc…, and use these to configure the =
utterance object. However, when I run the below code, all I get is =
Voiceover speaking with the default settings. No matter what I do, it =
seems that AVSpeechUtterance just is not picking up my custom user =
settings for Voiceover. To clarify, I have definitely changed the =
Voiceover default settings.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>from =
AVFoundation import AVSpeechSynthesizer<o:p></o:p></p><p =
class=3DMsoNormal>from AVFoundation import =
AVSpeechUtterance<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>voiceover =
=3D AVSpeechSynthesizer.alloc().init()<o:p></o:p></p><p =
class=3DMsoNormal>utterance =3D =
AVSpeechUtterance.speechUtteranceWithString_("hello =
world")<o:p></o:p></p><p =
class=3DMsoNormal>utterance.setPrefersAssistiveTechnologySettings_(True)<=
o:p></o:p></p><p =
class=3DMsoNormal>voiceover.speakUtterance_(utterance)<o:p></o:p></p><p =
class=3DMsoNormal>input()<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>Unfortunately, I do not know swift or ObjectiveC. I =
have been looking into them, and am trying to put together a test of =
this code in either language, but not having much luck =
yet.<o:p></o:p></p><p class=3DMsoNormal>Since this code runs, I really =
only have two guesses; either the property is not correctly configured =
in the python bindings, or I am wondering if I need to specify the =
Boolean differently here to work with the underlying ObjectiveC =
framework. Does anyone have an idea on what to do next? If this is not =
the correct place to ask, can someone point me in the right direction of =
where I can talk to someone who might know more about =
this?<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>Here is the AVSpeechSynthesizer =
documentation:<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal><a =
href=3D"https://developer.apple.com/documentation/avfaudio/avspeechsynthe=
sizer?language=3Dobjc">https://developer.apple.com/documentation/avfaudio=
/avspeechsynthesizer?language=3Dobjc</a><o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>Thanks,<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Timothy =
Breitenfeldt<o:p></o:p></p></div></body></html>
------=_NextPart_000_0608_01D825BE.C3931580--
--===============1767159106316866520==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Pythonmac-SIG maillist - [email protected]
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG
--===============1767159106316866520==--