Skip to content

Commit 1048d0a

Browse files
committed
- adding enable_tts config option
- adding \T to toggle TSS - TTS will speak titles and volume changes and playback start - TTS will speak when Radio Browser connection failure - fixing a vlc crash (volume calculation) - window_stack:close_window will speak selection - enabling Windows TTS (SAPI/win32com)
1 parent b2a53f9 commit 1048d0a

File tree

8 files changed

+142
-85
lines changed

8 files changed

+142
-85
lines changed

pyradio/config

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,9 @@ use_station_icon = True
126126
# Default value: True
127127
remove_station_icons = True
128128

129-
# Display Station Icons in the terminal
130-
# This is supported by a handful of terminals. If a capable terminal is
131-
# detected, this option will disable (default) or enable image display,
132-
# in which case, it will declare the maximum image size (in characters).
133-
#
134-
# Default value: 0 (disabled)
135-
icon_size = 0
129+
# TTS
130+
# Default value: False
131+
enable_tts = False
136132

137133
# Titles logging
138134
# If this option is True, PyRadio will start logging song titles to a log file

pyradio/config.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,8 @@ def _init_vars(self):
13601360
self.opts['enable_notifications'] = ['Enable notifications: ', '-1']
13611361
self.opts['use_station_icon'] = [' Use station icon: ', True]
13621362
self.opts['remove_station_icons'] = [' Remove cached icons: ', True]
1363+
self.opts['tts_title'] = ['TTS', '']
1364+
self.opts['enable_tts'] = [' Enable TTS: ', False]
13631365
self.opts['clock_title'] = ['Clock', '']
13641366
self.opts['enable_clock'] = ['Display on startup: ', False]
13651367
self.opts['time_format'] = ['Time format: ', '1']
@@ -1691,6 +1693,7 @@ def use_station_icon(self):
16911693
@use_station_icon.setter
16921694
def use_station_icon(self, val):
16931695
self.opts['use_station_icon'][1] = val
1696+
16941697
@property
16951698
def remove_station_icons(self):
16961699
return self.opts['remove_station_icons'][1]
@@ -1700,6 +1703,15 @@ def remove_station_icons(self, val):
17001703
self.opts['remove_station_icons'][1] = val
17011704
self.opts['dirty_config'][1] = True
17021705

1706+
@property
1707+
def enable_tts(self):
1708+
return self.opts['enable_tts'][1]
1709+
1710+
@enable_tts.setter
1711+
def enable_tts(self, val):
1712+
self.opts['enable_tts'][1] = val
1713+
self.opts['dirty_config'][1] = True
1714+
17031715
@property
17041716
def player(self):
17051717
return self.opts['player'][1]
@@ -2423,7 +2435,7 @@ def _read_config(self, distro_config=False):
24232435

24242436
try:
24252437
if distro_config:
2426-
# config μέσα στο package (system / wheel)
2438+
# config file in package (system / wheel)
24272439
cfg_res = files('pyradio').joinpath('config')
24282440
with as_file(cfg_res) as cfg_path:
24292441
with open(cfg_path, 'r', encoding='utf-8') as cfgfile:
@@ -2432,7 +2444,7 @@ def _read_config(self, distro_config=False):
24322444
else:
24332445
file_to_read = self.config_file
24342446
if not path.exists(file_to_read):
2435-
# user config δεν υπάρχει
2447+
# user config does not exist
24362448
self._make_sure_dirs_exist()
24372449
self._first_read = False
24382450
return
@@ -2544,6 +2556,11 @@ def _read_config(self, distro_config=False):
25442556
self.opts['remove_station_icons'][1] = False
25452557
else:
25462558
self.opts['remove_station_icons'][1] = True
2559+
elif sp[0] == 'enable_tts':
2560+
if sp[1].lower() == 'false':
2561+
self.opts['enable_tts'][1] = False
2562+
else:
2563+
self.opts['enable_tts'][1] = True
25472564
elif sp[0] == 'confirm_station_deletion':
25482565
if sp[1].lower() == 'false':
25492566
self.opts['confirm_station_deletion'][1] = False
@@ -2709,6 +2726,7 @@ def _read_config(self, distro_config=False):
27092726
self.opts['enable_mouse'][1] = False
27102727
self.opts['calculated_color_factor'][1] = '0'
27112728
self.opts['enable_clock'][1] = False
2729+
self.opts['enable_tts'][1] = False
27122730

27132731
''' check if default playlist exists '''
27142732
if self.opts['default_playlist'][1] != 'stations':

pyradio/config_window.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class PyRadioConfigWindow():
8080
_help_text.append(['Notice: Not applicable on Windows!', '|', 'Online Radio Directory Services (like RadioBrowser) will usually provide an icon for the stations they advertise.', '|', 'PyRadio can use this icon (provided that one exists and is of JPG or PNG format) while displaying Desktop Notifications.', '|', 'Setting this option to True, will enable the behavior above.', '|', 'If this option is False, the default icon will be used.', '|', 'Default value: True'])
8181
_help_text.append(['Notice: Not applicable on Windows!', '|', 'If the previous option is enabled, Stations Icons will be cached.', '|', 'If this option is set to True, all icons will be deleted at program exit.', '|', 'If set to False, the icons will be available for future use.', '|', 'Default value: True'])
8282
_help_text.append(None)
83+
_help_text.append(['Enable TTS', ])
84+
_help_text.append(None)
8385
_help_text.append(['If this option is enabled, the current time will be displayed at the bottom left corner of the window at program startup.', '|', 'Adjust the time format in the next option to change how the current time is displayed.', '|', r'You can always hide it by pressing ' + to_str('open_extra') + to_str('toggle_time') + '.', '|', 'Default value: False'])
8486
_help_text.append(['This is the time format to be used when the clock is visible.', '|', 'Available values are:', ' 0: 24h, with seconds', ' 1: 24h, no seconds', ' 2: 12h, with am/pm and seconds', ' 3: 12h, no am/pm, with seconds', ' 4: 12h, with am/pm, no seconds', ' 5: 12h, no am/pm, no seconds', '|', 'Default value: 1'])
8587
_help_text.append(None)
@@ -1153,7 +1155,8 @@ def keypress(self, char):
11531155
sel == 'log_titles' or \
11541156
sel == 'remove_station_icons' or \
11551157
sel == 'mplayer_save_br' or \
1156-
sel == 'continuous_playback':
1158+
sel == 'continuous_playback' or \
1159+
sel == 'enable_tts':
11571160
self._config_options[sel][1] = not self._config_options[sel][1]
11581161
# # if sel == 'open_last_playlist':
11591162
# # if self._config_options[sel][1]:

pyradio/keyboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def clear_input_queue():
153153
kbkey_orig['hist_top'] = ( ord(']') , 'Open first opened playlist')
154154
kbkey_orig['buffer'] = ( ord('b') , 'Toggle buffering')
155155
kbkey_orig['toggle_time'] = ( ord('t') , 'Toggle displaying time')
156+
kbkey_orig['toggle_tts'] = ( ord('T') , 'Toggle TTS')
156157
kbkey_orig['open_buffer'] = ( ord('B') , 'Open buffering window')
157158
kbkey_orig['last_playlist'] = ( ord('l') , 'Toggle Open last playlist')
158159
kbkey_orig['clear_reg'] = ( ord('c') , 'Clear current register')

0 commit comments

Comments
 (0)