+
    Qiw  c                  s   R t ^ RIHt RtRtRtRtRtRt^ RI	t	^ RI
t
^ RIt^ R	IHtHtHtHt ^ R
IHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIH t H!t! ]'       d   ^RIH"t" ^RIH#t#  ^ RI$t$Rt% ]&! ]$R4       Rt' ! R R]PT                  4      t*R#   ]( d    Rt' L"i ; i  ]) d    Rt% L1i ; i)z=Provides an Orca speech server for Speech Dispatcher backend.)annotationsz$Id$z
$Revision$z$Date$z Tomas Cerha <cerha@brailcom.org>z(Copyright (c) 2006-2008 Brailcom, o.p.s.ZLGPLN)TYPE_CHECKINGAnyCallableIterator)GLib)debug)focus_manager)	guilabels)mathsymbols)speechserver)settings)settings_manager)ACSS)AXUtilities)SSMLSSMLCapabilities)input_event)VoiceFamilyTCallbackTypeFc                  s  a  ] tR t^Ht$ Rt/ tR]R&   Rt]]P                  /t
]R R l4       t]R R l4       t]R	 R
 l4       t]RfR R ll4       t]R R l4       tR V 3R lltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR! R" ltRgR# R$ lltR% R& ltR' R( ltR) R* ltR+ R, lt RhR- R. llt!RhR/ R0 llt"RhR1 R2 llt#R3 R4 lt$R5 R6 lt%RiR7 R8 llt&R9 R: lt'RfR; R< llt(RfR= R> llt)RjR? R@ llt*RjRA RB llt+RkRC RD llt,RkRE RF llt-RkRG RH llt.RkRI RJ llt/RK RL lt0RM RN lt1RgRO RP llt2RfRQ RR llt3RgRS RT llt4RU RV lt5RW RX lt6RY RZ lt7R[ R\ lt8R] R^ lt9R_ R` lt:Ra Rb lt;Rc Rd lt<Ret=V ;t># )lSpeechServerz)Speech Dispatcher speech server for Orca.zdict[str, SpeechServer]_active_serversdefaultc                   V ^8  d   QhRR/#    returnstr Zformat   "A/usr/lib/python3.14/site-packages/orca/speechdispatcherfactory.py__annotate__SpeechServer.__annotate__Q   s     + +c +    c                 	s"    \         P                  # N)r   ZSPEECH_DISPATCHERr   r"   r   get_factory_nameZSpeechServer.get_factory_nameP   s    ***r"   c               r   )r   r   zlist[SpeechServer]r   r   r   r   r    r!   U   s     	 	 2 	r"   c                 	s    . p \         P                  \         P                  4      pVeU   V P                  V4       VP	                  4        F/  p\         P                  V4      pVf   K  V P                  V4       K1  	  V # r#   )r   _get_speech_serverDEFAULT_SERVER_IDappendlist_output_modules)serversr   Zmoduleservers       r   get_speech_serversZSpeechServer.get_speech_serversT   sk    11,2P2PQNN7#!557%88@%NN6* 8 r"   c                    V ^8  d   QhRRRR/# )r   	server_idr   r   SpeechServer | Noner   r   r   r   r    r!   a   s     2 23 23F 2r"   c                sh    WP                   9  d	   V ! V4       V P                   P                  V4      # )zReturn an active server for given id.

Attempt to create the server if it doesn't exist yet.  Returns None
when it is not possible to create the server.
)r   get)Zclsr-      &&r   r%   ZSpeechServer._get_speech_server`   s0     ///	N ""&&y11r"   c               r,   )r   infozlist[str] | Noner   r.   r   r   r   r   r    r!   o   s     8 8 0 8<O 8r"   c                sf    V e
   V ^,          M\         P                  p\         P                  V4      # )z.Gets a given SpeechServer based upon the info.)r   r&   r%   )r1   Zthis_id   & r   get_speech_serverZSpeechServer.get_speech_servern   s+     "-$q'<3Q3Q..w77r"   c               r   r   r   Noner   r   r   r   r    r!   v   s      T r"   c                 	s    \        \        P                  P                  4       4      p V  F  pVP	                  4        K  	  R # r#   )listr   r   Zvaluesshutdown)r)   r*   s     r   shutdown_active_serversZ$SpeechServer.shutdown_active_serversu   s/    |33::<=FOO r"   c               r,   )r   r-   r   r   r5   r   r   r   r   r    r!   }   s     0; 0;# 0;$ 0;r"   c                	s  < \         SV `  4        Wn        R V n        / V n        R V n        \        P                  V P                  3\        P                  V P                  3\        P                  V P                  3\        P                  V P                  33V n        \         '       g+   Rp\"        P$                  ! \"        P&                  VR4       R # \(        '       g+   Rp\"        P$                  ! \"        P&                  VR4       R #  \*        P,                  P.                  p\4        P6                  \*        P,                  P8                  \4        P:                  V\4        P<                  \*        P,                  P2                  \4        P>                  \*        P,                  P@                  /V n!        \*        PD                  PF                  \H        PJ                  PL                  \*        PD                  PN                  \H        PJ                  PP                  \*        PD                  PR                  \H        PJ                  PT                  \*        PD                  PV                  \H        PJ                  PL                  /V n,        \Z        P\                  V,          V n/         V Pa                  4        V \b        Pd                  V&   R #   \0         d    \*        P,                  P2                  p ELi ; i  \0         dQ    \"        Pf                  ! \"        P&                  4       Rp\"        P$                  ! \"        P&                  TR4        R # i ; i)Nz)ERROR: Speech Dispatcher is not availableTz<ERROR: Speech Dispatcher version 0.6.2 or later is required.z2ERROR: Speech Dispatcher service failed to connect)4Zsuper__init___id_client_current_voice_properties_current_synthesis_voicer   RATE	_set_rateAVERAGE_PITCH
_set_pitchGAIN_set_volumeFAMILY_set_family_acss_manipulators_SPEECHD_AVAILABLEr   print_messageLEVEL_WARNING_SPEECHD_VERSION_OKspeechdZPunctuationModeMOST	ExceptionSOMEr   PUNCTUATION_STYLE_ALLALLPUNCTUATION_STYLE_MOSTPUNCTUATION_STYLE_SOMEPUNCTUATION_STYLE_NONENONE_punctuation_mode_mapr   ZBEGINr
   SayAllContextPROGRESSZCANCELZINTERRUPTEDZEND	COMPLETEDZ
INDEX_MARK_callback_type_mapr   ZSPEECH_DEFAULT_VOICE_default_voice_name_initr   r   Zprint_exception)selfr-   msgZmost	__class__s   &&  r   r9   ZSpeechServer.__init__}   sT    9;&48%YY'1YY(()[[$**+	# "!=C 3 3S$?""PC 3 3S$?	0**//D **W-D-D-H-H++T++W-D-D-I-I++W-D-D-I-I	&"   &&(B(B(K(K  '')C)C)O)O  $$l&@&@&J&J  ++L,F,F,O,O	# $-#A#AI#M 	;JJL 7;L((31  	0**//D	0&  	@!!%"5"56FC 3 3S$?	@s%   K  K1 %K.-K.1AMMc               r   r4   r   r   r   r   r    r!      s     4 4t 4r"   c                	s    \         P                  ! R V P                  R7      ;V n        pTP                  \         P                  P                  4       T P                  '       dl   T P                  T P                  8w  dQ    TP                  4       pT P                  T9  d   T P                  T n        MTP                  T P                  4        / T n        T P$                  \&        P(                  ,          pTP+                  T4       TP-                  \         P.                  P0                  4       R#   \         P                  \         P
                  3 d>   pRT 2p\        P                  ! \        P                  TR4       RT n         Rp?R# Rp?ii ; i  \        \         P                   3 d    T P                  T n         Li ; i)ZOrca)Z	componentz/ERROR: Failed to connect to Speech Dispatcher: TN)rK   Z
SSIPClientr:   r;   SSIPCommunicationErrorZ
SpawnErrorr   rH   ZLEVEL_SEVEREZset_priorityZPriorityZMESSAGEr&   r(   set_output_moduleAttributeErrorSSIPCommandErrorr<   rU   r   verbalizePunctuationStyleset_punctuationZset_data_modeZDataModer   )r\   Zclienterrorr]   Zavailable_modulesmodes   &     r   r[   ZSpeechServer._init   s]   	$+$6$6v$RRDL6 	G,,445 888D$:$::2$*$>$>$@!88#44#55DH,,TXX6 *,&))(*L*LMt$W--223+ ..0B0BC 	CE7KC 2 2C>DL		  #G$<$<= 2112s/   )D5 2F 5F 5%F2FF,G	G	c               r   r4   r   r   r   r   r    r!      s      T r"   c                s   V P                   f   R# \        P                  \        P                  8X  d   RpM(\        P                  \        P                  8X  d   RpMRp V P                   P                  V4       R#   \        P                   di    Rp\        P                  ! \        P                  TR4       T P                  4        T P                   e   T P                   P                  T4        R#  R# \         d     R# i ; i)z;Updates the capitalization style used by the speech server.NZiconZspellZnone8SPEECH DISPATCHER: Connection lost. Trying to reconnect.T)r;   r   ZcapitalizationStyleZCAPITALIZATION_STYLE_ICONZCAPITALIZATION_STYLE_SPELLZset_cap_let_recognrK   r_   r   rH   
LEVEL_INFOresetrM   )r\   Zstyler]      &  r   update_capitalization_styleZ(SpeechServer.update_capitalization_style   s     <<''8+M+MME))X-P-PPEE		LL++E2-- 	7LC 0 0#t<JJL||'//6 ( 		s    A= =A6D9DDDc               r   r4   r   r   r   r   r    r!      s     + +$ +r"   c                s    V P                   f   R# V P                  \        P                  ,          pV P                   P	                  V4       R# )z5Punctuation level changed, inform this speechServer. N)r;   rU   r   rc   rd   )r\   rf   r2   r   update_punctuation_levelZ%SpeechServer.update_punctuation_level   s7    <<))(*L*LM$$T*r"   c               s(    V ^8  d   QhRRRRRRRR/# )r   commandzCallable[..., Any]argsr   kwargsr   r   r   r   r   r    r!      s*      %7  s WZ r"   c                	s    V! V/ VB #   \         P                   d    R p\        P                  ! \        P                  TR4       T P                  4        T P                  f    R#  T! T/ TB u #   \        \         P                  3 d8   pRT 2p\        P                  ! \        P                  TR4        Rp? R# Rp?ii ; i\         d     R# i ; i)rg   TNz(SPEECH DISPATCHER: Failed to reconnect: )rK   r_   r   rH   rh   ri   r;   ra   rb   rI   rM   )r\   rm   rn   ro   r]   re   s   &&*,  r   _send_commandZSpeechServer._send_command   s    	D+F++-- 	LC 0 0#t<JJL||#///"G$<$<= @H##E$7$7dC  		s@   
 AC)A30C3C+C 9C CCCCc               r,   )r   	acss_ratefloatr   r5   r   r   r   r   r    r!      s     8 85 8T 8r"   c           
     	s    V P                   f   R # \        ^\        ^ \        ^cV4      4      ,          ^b,
          4      pV P	                  V P                   P
                  V4       R # r#   )r;   intmaxminrp   Zset_rate)r\   rq   rate   && r   r?   ZSpeechServer._set_rate   sK    <<1s1c"i011B674<<00$7r"   c               r,   )r   
acss_pitchrr   r   r5   r   r   r   r   r    r!      s     : :U :t :r"   c           
     	s    V P                   f   R # \        ^\        ^ \        ^	V4      4      ,          ^Z,
          4      pV P	                  V P                   P
                  V4       R # r#   )r;   rs   rt   ru   rp   Z	set_pitch)r\   rx   pitchrw   r   rA   ZSpeechServer._set_pitch   sK    <<BQAz 233b894<<1159r"   c               r,   )r   acss_volumerr   r   r5   r   r   r   r   r    r!     s     < <u < <r"   c           
     	s    V P                   f   R # \        ^\        ^ \        ^	V4      4      ,          ^#,
          4      pV P	                  V P                   P
                  V4       R # r#   )r;   rs   rt   ru   rp   Z
set_volume)r\   rz   volumerw   r   rC   ZSpeechServer._set_volume  sK    <<R#aQ!455:;4<<22F;r"   c               r,   )r   acss_familydict[str, Any] | Noner   tuple[str, str]r   r   r   r   r    r!     s     + +5J + +r"   c                	s   Vf   / pVP                  \        P                  P                  4      pVP                  \        P                  P                  4      pV'       gV   \
        P                  ! 4       w  rERRr2V'       d4   VP                  R4      pV^ ,          p\        V4      ^8X  d
   V^,          p\        V4      \        V4      3# )N _)
r/   r
   r   LANGDIALECTlocale	getlocalesplitlenr   )r\   r|   languagedialectZfamily_localeZ	_encodingZlocale_values   &&     r   _get_language_and_dialectZ&SpeechServer._get_language_and_dialect  s    K??<#;#;#@#@A//,":":"B"BC'-'7'7'9$M "Bg - 3 3C 8(+}%*+A.G8}c'l**r"   c               r,   )r   r|   r}   r   r5   r   r   r   r   r    r!     s     9 9'< 9 9r"   c                	s.   V P                   f   R # V P                  V4      w  r#V'       dc   V P                  V P                   P                  V4       V'       d5   V P                  V P                   P                  VR,           V,           4        V P                   P                  pVe[   VP                  \        P                  P                  4      pVe,   WPP                  8w  d   V P                  WE4       WPn
        R # R # R # R #   \         d     R # i ; i)N-)r;   r   rp   set_languageset_synthesis_voicer/   r
   r   NAMErZ   r=   ra   )r\   r|   langr   r   name   &&    r   rE   ZSpeechServer._set_family  s    <<66{Ct||88$?""4<<#<#<dSj7>RS
	9"&,,"B"B &"|'?'?'D'DE#0H0H(H&&':A481 )I# '  		s   D DDc               r,   )r   prefixr   r   r5   r   r   r   r   r    r!   5  s     "9 "9s "9D "9r"   c                	s   \         P                  \         P                  8  d   R #  V P                  e   V P	                  V P                  P
                  4      pV P	                  V P                  P                  4      pV P	                  V P                  P                  4      pV P	                  V P                  P                  4      pMR;p;p;rE V P                  P                  \        P                  4      ;'       g    / p\        P                  R\        P                   R\        P"                  R\        P$                  R/pVP                  \&        P(                  ! 4       P+                  R4      R4      pR	V R
V P                  P                  \        P,                  4       RV P                  P                  \        P.                  4       RV P                  P                  \        P0                  4       RV P3                  V4      ^ ,           RV RV RV RV RV 2p	\         P4                  ! \         P                  V	R4       R #   \         d    R;p;p;rE ELi ; i)Nz(client not available)z(exception occurred)rT   rN   rL   rP   rc   ZUNKNOWNzSPEECH DISPATCHER: z
ORCA rate z, pitch z	, volume z, language z, punctuation: z	
SD rate T)r   Z
debugLevelrh   r;   rp   Zget_rateZ	get_pitchZ
get_volumeget_languagerM   r<   r/   r   rD   r   rS   rR   rQ   rO   r   get_managerZget_settingr>   r@   rB   r   rH   )
r\   r   Zsd_rateZsd_pitchZ	sd_volumeZsd_languagefamilyZstylesZpunctuation_styler]   s
   &&        r   _debug_sd_valuesZSpeechServer._debug_sd_values5  s(   e...		R||',,T\\-B-BC--dll.D.DE ..t||/F/FG	"001J1JK?WWW(WY //33DKK@FFB11611611600%9
 #JJ((*667RSU^` "& *77;;DIIFG H33778J8JKL M4488CD E66v>qAB C-. /ixz9+[Q\P]_ 	 	E,,c48-  	R;QQGQhQ[	Rs   B"I 
I I$#I$c               r,   )r   acssr}   r   r5   r   r   r   r   r    r!   Y  s     , , 5 ,$ ,r"   c                	sp   Vf&   \         P                  \         P                  ,          pV P                  pV P                   F  w  r4VP                  V4      pVe'   VP                  V4      V8w  d   V! V4       WRV&   K>  K@  V\        P                  8X  d   V P                  R4       RW#&   Kl  V\        P                  8X  d   V P                  R4       RW#&   K  V\        P                  8X  d   V P                  R4       RW#&   K  V\        P                  8X  g   K  V P                  / 4       / W#&   K  	  R # )Ng      @g      $@g      I@)r   voicesDEFAULT_VOICEr<   rF   r/   r   r@   rA   rB   rC   r>   r?   rD   rE   )r\   r   ZcurrentZacss_propertyZmethodZvaluer   r   _apply_acssZSpeechServer._apply_acssY  s    <??8#9#9:D00%)%<%<!MHH]+E ;;}-65M-2M* 7 $"4"44$),&$))+  &)-&$))+t$)-&$++-  $)+&# &=r"   c               (    V ^8  d   QhRRRRRRRR/# )	r   textr   r   r}   ro   r   r   r5   r   r   r   r   r    r!   p  s/     	C 	C3 	C&; 	Cs 	Ct 	Cr"   c                	s<   \        V\        4      '       d   R p\        P                  ! V\        P
                  4      pV P                  V4       V P                  RV R24       V P                  e+   V P                  ! V P                  P                  V3/ VB  R# R# )r   z
Speaking 'z' N)Z
isinstancer   r   Zmarkup_textr   ZMARKr   r   r;   rp   speak)r\   r   r   ro   ssmls   &&&, r   _speakZSpeechServer._speakp  s    dD!!D&6&;&;<
4&34<<#t||114B6B $r"   c               $    V ^8  d   QhRRRRRR/# )r   iterator;Iterator[tuple[speechserver.SayAllContext, dict[str, Any]]]orca_callback1Callable[[speechserver.SayAllContext, int], None]r   boolr   r   r   r   r    r!   {  s)     , ,M, I, 
	,r"   c           	     s   a aaa  \        S4      w  opRVVVV 3R llpS P                  SP                  W4\        S P                  P                  4       4      R7       R#   \         d     R# i ; i)z<Process another sayAll chunk.

Called by the gidle thread.

c                s  < S
P                   V ,          pV\        P                  P                  8X  d   V'       d   VP	                  R 4      p\        V4      ^8  d   VR,          w  rESP                  \        V4      ,           Sn        SP                  \        V4      ,           Sn	        RSP                   R SP                   RSP                   R SP                   2p\        P                  ! \        P                  VR4       MPSP                  Sn        RSn	        M7V\        P                  P                  8X  d   SP                  Sn        RSn	        \        P                   ! S	SP#                  4       V4       V\        P                  P                  8X  d%   \        P                   ! S
P$                  SS	4       R# R# )Z::    r   NzSPEECH DISPATCHER: Got mark z / TN)rY   r
   rV   rW   r   r   Zstart_offsetrs   Zcurrent_offsetZcurrent_end_offsetZ
end_offsetr   rH   rh   rX   r   idle_addZcopy_say_all)Zcallback_typeZ
index_markZtZindexstartZendr]   contextr   r   r\   s   &&     r   callbackZ'SpeechServer._say_all.<locals>.callback  se    ++M:22;;;! * 0 0 5u:?).sJE5<5I5ICPUJ5VG29@9M9MPSTWPX9XG6">#*#9#9":!G<V<V;WWZ#*#7#7"8':L:L9M!O  
 "//0@0@#tL181E1E.592,44>>>-4-?-?G*15G.mW\\^Q?22<<<MM$--=I =r"   )r   Zevent_typesFr#   )Znextr   Z	utterancer6   rY   ZkeysZStopIteration)r\   r   r   r   r   r   s   fff  @r   r   ZSpeechServer._say_all{  su    !	J NMGTJ J6 KK))4$()@)@)E)E)G$H  JA  	> A	s   A   A/.A/c               r   r4   r   r   r   r   r    r!     s     4 4 4r"   c                	sp    V P                   e(   V P                  V P                   P                  4       R # R # r#   )r;   rp   Zcancelr\      &r   _cancelZSpeechServer._cancel  s)    <<#t||223 $r"   c               r   )r   steprs   decreaser   r   r5   r   r   r   r   r    r!     s"     	9 	9 	9t 	9PT 	9r"   c                	s   \         P                  \         P                  ,          pY;'       d    R;'       g    ^,          p V\        P                  ,          p\        ^ \        ^cWT,           4      4      V\        P                  &   RV 2p\        P                  ! \        P                  VR4       R#   \
         d    ^2p Lii ; i)   zSPEECH DISPATCHER: Rate set to TN)r   r   r   r   r>   KeyErrorrt   ru   r   rH   rh   )r\   r   r   r   deltarv   r]      &&&    r   _change_default_speech_rateZ(SpeechServer._change_default_speech_rate  s    x556R--2.			?D aR!67TYY/v6E,,c48	  	D	   B4 4CCc               r   r   r   rr   r   r   r   r5   r   r   r   r   r    r!     s"     	9 	9 	9$ 	9SW 	9r"   c                	s   \         P                  \         P                  ,          pY;'       d    R;'       g    ^,          p V\        P                  ,          p\        ^ \        ^	WT,           4      4      V\        P                  &   RV 2p\        P                  ! \        P                  VR4       R#   \
         d    ^p Lii ; i)r   z SPEECH DISPATCHER: Pitch set to TNr   )r   r   r   r   r@   r   rt   ru   r   rH   rh   )r\   r   r   r   r   ry   r]   r   r   _change_default_speech_pitchZ)SpeechServer._change_default_speech_pitch  s    x556R--2.	++,E $'q#a*?#@T 08E,,c48	  	E	r   c               r   r   r   r   r   r   r    r!     s"     	9 	9% 	94 	9TX 	9r"   c                	s   \         P                  \         P                  ,          pY;'       d    R;'       g    ^,          p V\        P                  ,          p\        ^ \        ^	WT,           4      4      V\        P                  &   RV 2p\        P                  ! \        P                  VR4       R#   \
         d    ^
p Lii ; i)r   z!SPEECH DISPATCHER: Volume set to TNr   )r   r   r   r   rB   r   rt   ru   r   rH   rh   )r\   r   r   r   r   r{   r]   r   r   _change_default_speech_volumeZ*SpeechServer._change_default_speech_volume  s    x556R--2.	$))_F aQ!78TYY1&:E,,c48	  	F	r   c               r   )r   r   z	list[str]r   r   r   r   r    r!     s     F F) Fr"   c                	sz    V P                   P                  V P                  V P                  4      V P                  .# r#   )_SERVER_NAMESr/   r:   r   r   r   get_infoZSpeechServer.get_info  s,    ""&&txx:DHHEEr"   c               r   )r   r   zlist[speechserver.VoiceFamily]r   r   r   r   r    r!     s     2 2$B 2r"   c                	s   \         P                  ! \         P                  4      ^ ,          pVe   RV9  d   RpM#VP                  R4      w  r4VR,           V,           pRpV P                  e=    V P                  P
                  p V P                  V4      pV'       d   \        V4      pRpV'       d@   V F  w  rpW8X  g   K  Tp M	  V'       g   V F  w  rpV
X8X  g   K  TpK  	  V'       g   TpV P                  VR33V,           p. pV F  w  rpVP                  \        P                  ! \        P                  P                  V	\        P                  P                  V
P!                  R4      ^ ,          \        P                  P"                  V
P!                  R4      ^,          \        P                  P$                  V/4      4       K  	  V#   \         d     EL7i ; i  \         d     ELIi ; i)r   Nr   r   r   r   )r   r   ZLC_MESSAGESr   r;   list_synthesis_voicesrp   ZtuplerM   ra   rZ   r'   r
   r   r   r   	partitionr   VARIANT)r\   Zcurrent_localeZlocale_languageZlocale_langZlocale_dialectr   r   resultZdefault_langr   r   Zvariantfamiliess   &            r   get_voice_familiesZSpeechServer.get_voice_families  s     ))&*<*<=a@!S%>"O*8*>*>s*C'K)C/.@O:<<<#(,(J(J%!//0EFF!&v '-#G*#2L (.  +1'D{*'2 ,2  .++\4@BVK#)DOOL44&&++T&&++T^^C-@-C&&..s0CA0F&&..69 : ; $* ; !  " s$   .G$ $G G! G!$G32G3c               r   )	r   r   z
str | Noner   r}   	interruptr   r   r5   r   r   r   r   r    r!     s2     $ $$ $$ 	$
 
$r"   c                	s   V'       g   R # \        V4      ^8X  dv   RV R2p\        P                  ! \        P                  VR4       V P	                  V4       V P
                  e)   V P                  V P
                  P                  V4       R # R # RV R2p\        P                  ! \        P                  VR4       V P                  W4       R # )NSPEECH DISPATCHER: Speaking '	' as charT' as string)	r   r   rH   rh   r   r;   rp   charr   )r\   r   r   r   r]   s   &&&& r   r   ZSpeechServer.speak  s      t9>1$yAC 0 0#t<T"||'""4<<#4#4d; ( 2${CC 0 0#t<KK#r"   c               r   )r   utterance_iteratorr   progress_callbackr   r   r5   r   r   r   r   r    r!   !  s.     L LWL ML 
	Lr"   c                sH    \         P                  ! V P                  W4       R# )zGIterates through the given utterance_iterator, speaking each utterance.N)r   r   r   )r\   r   r      &&&r   say_allZSpeechServer.say_all!  s     	dmm%7Kr"   c               r   )r   	characterr   r   r}   r   r5   r   r   r   r   r    r!   *  s#       4I UY r"   c                s   V P                  V4       Tp\        P                  ! 4       P                  4       p\        P
                  ! V4      '       d   \        P                  ! V4      pV'       d   W18X  dc   RV R2p\        P                  ! \        P                  VR4       V P                  e'   V P                  V P                  P                  V4       R# V P                  W24       R# )zSpeaks character.r   r   TN)r   r   r   Zget_locus_of_focusr   Zis_math_relatedr	   Zget_character_namer   rH   rh   r;   rp   r   r   )r\   r   r   r   Zfocusr]      &&&   r   speak_characterZSpeechServer.speak_character*  s     	))+>>@&&u-- 11)<Dt(1)IFC 0 0#t<||'""4<<#4#4i@

4r"   c               r   )r   eventzinput_event.KeyboardEventr   r}   r   r5   r   r   r   r   r    r!   >  s(     0 0(0 $0 
	0r"   c                s   VP                  4       pVP                  4       pV RV 2P                  4       p\        V4      ^8X  dv   RV R2p\        P
                  ! \        P                  VR4       V P                  V4       V P                  e)   V P                  V P                  P                  V4       R# R# RV R2p\        P
                  ! \        P                  VR4       V P                  W2R7       R# )zSpeaks event.Z r   z' as keyTNr   )r   )Zget_key_nameZget_locking_state_stringZstripr   r   rH   rh   r   r;   rp   Zkeyr   )r\   r   r   Zevent_stringZlocking_state_stringr]   r   r   speak_key_eventZSpeechServer.speak_key_event>  s     ))+$==?&q)=(>?EEG|!1,xHC 0 0#t<T"||'""4<<#3#3\B ( 2,{KC 0 0#t<JJ|J/r"   c               r,   r   r   rs   r   r5   r   r   r   r   r    r!   S  s     / / /T /r"   c                	(    V P                  V4       R # r#   r   r\   r   r0   r   increase_speech_rateZ!SpeechServer.increase_speech_rateS  s    ((.r"   c               r,   r   r   r   r   r   r    r!   V  s     > > >T >r"   c                	,    V P                  VR R7       R# T)r   Nr   r   r0   r   decrease_speech_rateZ!SpeechServer.decrease_speech_rateV  s    (((=r"   c               r,   r   r   rr   r   r5   r   r   r   r   r    r!   Y  s     0 0% 0$ 0r"   c                	r   r#   r   r   r0   r   increase_speech_pitchZ"SpeechServer.increase_speech_pitchY  s    ))$/r"   c               r,   r   r   r   r   r   r    r!   \  s     ? ?% ?$ ?r"   c                	r   r   r   r   r0   r   decrease_speech_pitchZ"SpeechServer.decrease_speech_pitch\  s    ))$)>r"   c               r,   r   r   r   r   r   r    r!   _  s     1 15 14 1r"   c                	r   r#   r   r   r0   r   increase_speech_volumeZ#SpeechServer.increase_speech_volume_  s    **40r"   c               r,   r   r   r   r   r   r    r!   b  s     @ @5 @4 @r"   c                	r   r   r   r   r0   r   decrease_speech_volumeZ#SpeechServer.decrease_speech_volumeb  s    **4$*?r"   c               r   r   r   r   r   r   r    r!   e  s     + +c +r"   c                sV    V P                   f   R# V P                   P                  4       # )zReturns the current language.r   )r;   r   r   r   r   r   ZSpeechServer.get_languagee  s$     <<||((**r"   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r5   r   r   r   r   r    r!   l  s&     @ @S @3 @4 @r"   c                s    V'       d   V P                   f   R# V P                   P                  V4       V'       d,   V P                   P                  VR,           V,           4       R# R# )zSets the current languageNr   )r;   r   )r\   r   r   r   r   r   ZSpeechServer.set_languagel  sH     4<</!!(+LL%%hnw&>? r"   c               r   )r   r   r   r   r   r~   r   r   r   r   r    r!   v  s"     
7 
7 
7s 
7Tc 
7r"   c                s    RV9   dR   VP                  R^4      ^ ,          P                  4       pVP                  R^4      R,          P                  4       pW43# VP                  4       pVP                  4       pW43# )z;Attempts to ensure consistency across inconsistent formats.r   r   )r   Zlower)r\   r   r   normalized_languagenormalized_dialects   &&&  r    _normalized_language_and_dialectZ-SpeechServer._normalized_language_and_dialectv  sx     (?"*..a"8";"A"A"C!)Q!7!;!A!A!C
 #66 #+.."2!("66r"   c               s(    V ^8  d   QhRRRRRRRR/# )r   r   r   r   maximumz
int | Noner   z!list[tuple[str, str, str | None]]r   r   r   r   r    r!     s2     $ $$ $ 	$
 
+$r"   c           	     sT   \         P                   ! 4       pV P                  W4      w  rV. pV P                  f   V# V P                  P                  4       pV Ft  p	V P                  V	^,          4      w  rW8w  d   K%  W8X  d   VP	                  V	4       MV'       g   Wj8X  d   VP	                  V	4       Vf   Kb  \        V4      V8  g   Kt   M	  R\        V4       RV RV R\         P                   ! 4       V,
          R R2	p\        P                  ! \        P                  VR4       V# )zGReturns the families for language available in the current synthesizer.zSPEECH DISPATCHER: Found z match(es) for language='z' dialect='z' in z.4fzs.T)	timer   r;   r   r'   r   r   rH   rh   )r\   r   r   r   r   Ztarget_languageZtarget_dialectr   Z
all_voicesZvoicer   r   r]   s   &&&&         r   get_voice_families_for_languageZ,SpeechServer.get_voice_families_for_language  s    		*.*O*OPX*b'<<M
 \\779
E55eAh? 4"5!3e$'N,Qe$"s6{g'=   (F}4MhZ XydiikE&9#%>bB 	 	E,,c48r"   c               r   )r   r   r   r   r   r   r   r   r   r   r    r!     s(        
	r"   c           	     sT   V P                  V P                  4       4      w  r4V P                  W4      w  rVRV RV RV RV R2	p\        P                  ! \        P                  VR4       W58X  d1   WF8X  d+   Rp\        P                  ! \        P                  VR4       R# V P                  WV^R7      pV'       d5   R	V^ ,          R
.p	\        P                  ! \        P                  V	R4       R# RV P                  4       R
.p	\        P                  ! \        P                  V	R4       R# )zFReturns True if we should change the voice for the specified language.z?SPEECH DISPATCHER: Should change voice for language? Current: 'z' 'z' New: 'Z'Tz9SPEECH DISPATCHER: No. Language and dialect are the same.F)r   z-SPEECH DISPATCHER: Yes. Found matching familyZ.z,SPEECH DISPATCHER: No. No matching family in)r   r   r   rH   rh   r   Zprint_tokensget_output_module)
r\   r   r   Zcurrent_languageZcurrent_dialectZother_languageZother_dialectr]   r   Ztokenss
   &&&       r    should_change_voice_for_languageZ-SpeechServer.should_change_voice_for_language  s!    11$2C2C2EF 	*(,(M(Mh(`%)*#o-> ?#$Ca9 	
 	E,,c48-/2RLC 0 0#t<77_`7aExPQ{TWXFu//>@$BXBXBZ\_`5++VT:r"   c               r   r   r   r   r   r   r    r!     s      3 r"   c                	s|    V P                   f   R# V P                  V P                   P                  4      pVe   V# R# )Nr   )r;   rp   r   )r\   r   r2   r   r   ZSpeechServer.get_output_module  s7    <<##DLL$B$BCMr"   c               r,   )r   	module_idr   r   r5   r   r   r   r   r    r!     s     J J3 J4 Jr"   c                sr    V P                   e)   V P                  V P                   P                  V4       R# R# )z7Set the speech output module to the specified provider.N)r;   rp   r`   )r\   r   r0   r   r`   ZSpeechServer.set_output_module  s-     <<#t||==yI $r"   c               r   r4   r   r   r   r   r    r!     s      d r"   c                	s&    V P                  4        R # r#   )r   r   r   r   stopZSpeechServer.stop  s    r"   c               r   r4   r   r   r   r   r    r!     s     ; ;$ ;r"   c                	s(    V P                   e7   V P                   P                  4        R V n         \        P                  ! 4        T P
                  \        P                  9   d   \        P                  T P
                   R # R #   \         dC   pRT P
                   RT 2p\        P                  ! \        P                  TR4        R p?LR p?ii ; i  T P
                  \        P                  9   d   \        P                  T P
                   i i ; i)Nz3SPEECH DISPATCHER: Error during shutdown of server : T)r;   closegcZcollectrM   r:   r   rH   rI   r   r   )r\   re   r]   rj   r   r7   ZSpeechServer.shutdown  s    	; ||'""$# 


 xx<777 00: 8	  	@GzQSTYSZ[C 3 3S$??	@ xx<777 00: 8s*   AB C8CC CC =Dc               r   r4   r   r   r   r   r    r!     s     
 
t 
r"   c                	s    R V P                    2p\        P                  ! \        P                  VR4       V P                  e   V P                  P                  4        T P                  4        R#   \         dC   pRT P                    RT 2p\        P                  ! \        P                  TR4        Rp?LZRp?ii ; i  T P                  4        i ; i)z$SPEECH DISPATCHER: Resetting server TNz0SPEECH DISPATCHER: Error during reset of server r   )	r:   r   rH   rh   r;   r   rM   rI   r[   )r\   r]   re   rj   r   ri   ZSpeechServer.reset  s    		8
CC 0 0#t<||'""$
 JJL	  	@DTXXJbQVPWXC 3 3S$??	@ JJLs*   AA1 1B><8B94C 9B>>C Cc               r   )r   r   ztuple[str, ...]r   r   r   r   r    r!     s     
 
_ 
r"   c                s    V P                   f   R#  V P                  V P                   P                  4      #   \         d    Ru # \        P
                   d    Ru # i ; i)z?Return names of available output modules as a tuple of strings.r   )r;   rp   r(   ra   rK   rb   r   r   r   r(   Z SpeechServer.list_output_modules  sZ     <<I	%%dll&F&FGG 	I'' 	I	s   $7 AAAAc               r   )r   r   r   r   r   r   r   r    r!     s     
 
+ 
r"   c           
     sz   V P                   ;'       g    V P                  pRp V P                  V P                  P                  4      pVP                  R4      pV^ ,          pV^,          p\        P                  ! \        P                  P                  V\        P                  P                  V\        P                  P                   V\        P                  P"                  R/4      #   \
        \        P                  3 d6   pRT 2p\        P                  ! \        P                  TR4        Rp?LRp?ii ; i)z=Returns the current voice family as a VoiceFamily dictionary.r   z+SPEECH DISPATCHER: Error getting language: TNr   )r=   rZ   rp   r;   r   ra   rK   rb   r   rH   rI   r   r
   r   r   r   r   r   )r\   
voice_namer   re   r]   Z
lang_partsr   r   s   &       r   get_voice_familyZSpeechServer.get_voice_family  s    22NNd6N6N
	@))$,,*C*CDH
 '',
!}Q-'''',,j'',,d''//''//	
 	
  8 89 	@?wGC 3 3S$??	@s   %C* *D:+D55D:c               r,   )r   r   r   r   r5   r   r   r   r   r    r!     s     D D{ Dt Dr"   c                s   V'       g   R# VP                  \        P                  P                  R4      pVP                  \        P                  P                  R4      pVP                  \        P                  P
                  R4      pV'       d   V'       d   V RV 2MTpV'       d.    V P                  V P                  P                  V4       W n	        V'       d*    V P                  V P                  P"                  V4       R# R#   \         d=   pRT 2p\        P                  ! \        P                  TR4       RT n	         Rp?LuRp?i\        P                   d9   pRT RT 2p\        P                  ! \        P                   TR4        Rp?LRp?ii ; i  \        P                   d:   pRT RT 2p\        P                  ! \        P                   TR4        Rp?R# Rp?ii ; i)	z7Sets the voice family to family VoiceFamily dictionary.Nr   r   z2SPEECH DISPATCHER: Synthesis voice not supported: Tz1SPEECH DISPATCHER: Error setting synthesis voice r   z*SPEECH DISPATCHER: Error setting language )r/   r
   r   r   r   r   rp   r;   r   r=   ra   r   rH   rh   rK   rb   rI   r   )r\   r   r   r   r   re   r]   r   r   set_voice_familyZSpeechServer.set_voice_family  s    ZZ 8 8 = =rB
::l66;;R@**\55==rB2:(1WI.H 	D""4<<#C#CZP0:- D""4<<#<#<hG  " 5J5'R##E$4$4c4@04--++ DI*UWX]W^_##E$7$7dCCD ++ DB8*BugV##E$7$7dCCDsB   +,D
  &F 
F2EF#F$.FFG-4.G((G-)rF   rY   r;   r=   r<   rZ   r:   rU   r#   )r   )F)NNT)i   )g      ?)?Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   Z__annotations__r&   r   ZDEFAULT_SYNTHESIZERr   Zstaticmethodr$   r+   Zclassmethodr%   r3   r8   r9   r[   rk   rl   rp   r?   rA   rC   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r`   r   r7   ri   r(   r   r   Z__static_attributes__Z__classcell__)r^   s   @r   r   r   H   sx   3/1O,1!&	(E(EFM+ + 	 	 2 2 8 8  0; 0;d440+$8:<+&9,"9H,.	C,\4	9	9	9F2h$8L(0*/>0?1@+@
7$LBJ;$


.D Dr"   r   )+r   Z
__future__r    Z__id__Z__version__Z__date__Z
__author__Z__copyright__Z__license__r   r   r   Ztypingr   r   r   r   Zgi.repositoryr   r   r   r   r   r	   r
   r   r   r   r   Zax_utilitiesr   r   r   r   r   r   rK   rG   ZgetattrrJ   ra   rM   r   r   r"   r   <module>r      s   2 D #	2
: 	   9 9          % ()# #( #tD<,, tD  $#$  s$   B> 	B/ /	B;:B;>	C
	C
