5858from .messages_system import PyRadioMessagesSystem
5959from .server import PyRadioServer, HAS_NETIFACES
6060from .keyboard import kbkey, get_lkbkey, get_unicode_and_cjk_char, dequeue_input, input_queue, set_kb_letter, check_localized, add_l10n_to_functions_dict, set_kb_cjk
61- from .tts import TTSManager
61+ from .tts import TTSManager, Priority
6262HAVE_CHARSET_NORMALIZER = True
6363try:
6464 from .m3u import parse_m3u
@@ -263,7 +263,6 @@ def keypress(self, char):
263263
264264class PyRadio():
265265 player = None
266- ws = Window_Stack()
267266
268267 _i_am_resizing = False
269268 _redisplay_list = []
@@ -512,6 +511,7 @@ def __init__(self, pyradio_config,
512511 in log.write, if _current_player_id != _active_player_id
513512 do not display any message
514513 '''
514+ self.ws = Window_Stack(self._speak_selection)
515515 self.player = None
516516 # player data
517517 self._default_player_name = None
@@ -1047,7 +1047,7 @@ def _set_text_volume(self, vol):
10471047 # self._remote_control_server._send_text('Volume set!')
10481048 self.player.set_volume(vol)
10491049 sleep(.1)
1050- return f'Volume set to: {vol}'
1050+ return M_STRINGS['volume_set'] + f' {vol}'
10511051 else:
10521052 if self.player.muted:
10531053 return 'Player is Muted!'
@@ -1251,7 +1251,8 @@ def setup(self, stdscr):
12511251 self._cnf,
12521252 lambda: self._current_player_id,
12531253 lambda: self._active_player_id,
1254- lambda: self._remote_control_server
1254+ lambda: self._remote_control_server,
1255+ lambda: self.tts
12551256 )
12561257 self.log.program_restart = self.program_restart
12571258 self.program_restart = False
@@ -1287,6 +1288,7 @@ def setup(self, stdscr):
12871288 self.player.log = self.log
12881289 self.player.handle_old_referer = self._handle_old_referer
12891290 self.player.update_bitrate = self._update_bitrate
1291+ self.player.tts = lambda: self.tts
12901292 if self._request_recording:
12911293 if not (platform.startswith('win') and \
12921294 self.player.PLAYER_NAME == 'vlc'):
@@ -2217,6 +2219,8 @@ def run(self):
22172219
22182220 self._cnf.setup_mouse()
22192221
2222+ self._speak_selection()
2223+
22202224 if not self._cnf.use_themes \
22212225 and not self._cnf.no_themes_notification_shown \
22222226 and not self._cnf.no_themes_from_command_line:
@@ -4191,7 +4195,8 @@ def _open_playlist(self, a_url=None):
41914195 if not self._cnf._online_browser.initialize():
41924196 ''' browser cannot be opened '''
41934197 self._cnf.remove_from_playlist_history()
4194- self.ws.close_window()
4198+ self.ws.close_window(no_tts=True)
4199+ self._speak_high('Error, cannot connect to Radio Browser')
41954200 self._print_service_connection_error()
41964201 self._cnf.browsing_station_service = False
41974202 self._cnf.online_browser = None
@@ -4202,6 +4207,7 @@ def _open_playlist(self, a_url=None):
42024207
42034208 ''' make sure we don't send a wrong click '''
42044209 self._cnf._online_browser.search()
4210+ self._speak_selection()
42054211 else:
42064212 self._cnf.remove_from_playlist_history()
42074213 self._open_simple_message_by_key(
@@ -4635,6 +4641,7 @@ def _open_playlist_from_history(self,
46354641 # self._cnf.save_last_playlist()
46364642 if result:
46374643 self._normal_mode_resize()
4644+ self._speak_selection()
46384645 return result
46394646
46404647 def _get_station_id(self, find):
@@ -6659,6 +6666,7 @@ def _activate_player(self, player_name):
66596666 self.player.update_bitrate = self._update_bitrate
66606667 self.player.log = self.log
66616668 self.player.handle_old_referer = self._handle_old_referer
6669+ self.player.tts = lambda: self.tts
66626670 if not (self.player.PLAYER_NAME == 'vlc' and \
66636671 platform.startswith('win')):
66646672 self.player.recording = to_record
@@ -6747,11 +6755,17 @@ def _exit_program_or_playlist_mode(self):
67476755 self._cnf.EXTERNAL_PLAYER_OPTS = None
67486756 return False
67496757
6758+ def _speak_high(self, msg):
6759+ self.tts.queue_speech(msg, Priority.HIGH)
6760+
6761+ def _speak_normal(self, msg):
6762+ self.tts.queue_speech(msg, Priority.NORMAL)
6763+
67506764 def _speak_selection(self):
67516765 if self.ws.operation_mode == self.ws.NORMAL_MODE:
6752- self.tts.speak (f'Selected station: {self.stations[self.selection][0]}')
6766+ self.tts.queue_speech (f'{self.selection+1}. {self.stations[self.selection][0]}', Priority.NORMAL )
67536767 elif self.ws.operation_mode == self.ws.PLAYLIST_MODE:
6754- self.tts.speak (f'Selected playlist: {self.stations[self.selection][0]}')
6768+ self.tts.queue_speech (f'{self.selection+1}. {self.stations[self.selection][0]}', Priority.NORMAL )
67556769
67566770 def keypress(self, char):
67576771 ''' PyRadio keypress '''
@@ -9760,6 +9774,7 @@ def keypress(self, char):
97609774 self._update_status_bar_right()
97619775 if self.number_of_items > 0:
97629776 self.setStation(-1)
9777+ self._speak_selection()
97639778 self.refreshBody()
97649779 return
97659780
@@ -9768,6 +9783,7 @@ def keypress(self, char):
97689783 self._jump_to_jumpnr(char)
97699784 self.refreshBody()
97709785 self._reset_status_bar_right()
9786+ self._speak_selection()
97719787 return
97729788
97739789 if char in map(ord, map(str, range(0, 10))):
@@ -9786,6 +9802,7 @@ def keypress(self, char):
97869802 self._update_status_bar_right()
97879803 self.setStation(0)
97889804 self.refreshBody()
9805+ self._speak_selection()
97899806 return
97909807
97919808 if char in (curses.KEY_EXIT, kbkey['q'], 27) or \
0 commit comments