Debian Codegraph @

src/fenrirscreenreader/speechDriver/debugDriver.py

raw
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Fenrir TTY screen reader
5 # By Chrys, Storm Dragon, and contributors.
6 # generic driver
7
8 from fenrirscreenreader.core import debug
9 from fenrirscreenreader.core.speechDriver import speech_driver
10
11
12 class driver(speech_driver):
13 """Debug speech driver for Fenrir development and testing.
14
15 This driver provides speech output to console/debug output instead of
16 actual audio, making it useful for development, testing, and debugging
17 scenarios where audio output is not needed or available.
18
19 All speech operations are logged to console with descriptive messages,
20 allowing developers to trace speech behavior without audio hardware.
21 """
22 def __init__(self):
23 speech_driver.__init__(self)
24
25 def initialize(self, environment):
26 """Initialize the debug speech driver.
27
28 Args:
29 environment: Fenrir environment dictionary
30 """
31 self._is_initialized = True
32 self.env = environment
33 print("Speech Debug Driver: Initialized")
34
35 def shutdown(self):
36 """Shutdown the debug speech driver."""
37 if self._is_initialized:
38 self.cancel()
39 self._is_initialized = False
40 print("Speech Debug Driver: Shutdown")
41
42 def speak(self, text, queueable=True, ignore_punctuation=False):
43 """Output speech text to console for debugging.
44
45 Args:
46 text (str): Text to speak
47 queueable (bool): Whether speech can be queued
48 ignore_punctuation (bool): Whether to ignore punctuation
49 """
50 if not self._is_initialized:
51 return
52 if not queueable:
53 self.cancel()
54 print("Speech Debug Driver: Speak:" + text)
55 print("Speech Debug Driver: -----------------------------------")
56
57 def cancel(self):
58 """Log speech cancellation to console."""
59 if not self._is_initialized:
60 return
61 print("Speech Debug Driver: Cancel")
62
63 def set_callback(self, callback):
64 """Log callback setting to console.
65
66 Args:
67 callback: Callback function (logged but not used)
68 """
69 print("Speech Debug Driver: set_callback")
70
71 def clear_buffer(self):
72 """Log buffer clearing to console."""
73 if not self._is_initialized:
74 return
75 print("Speech Debug Driver: clear_buffer")
76
77 def set_voice(self, voice):
78 """Log voice setting to console.
79
80 Args:
81 voice: Voice setting (logged but not used)
82 """
83 if not self._is_initialized:
84 return
85 print("Speech Debug Driver: set_voice:" + str(voice))
86
87 def set_pitch(self, pitch):
88 """Log pitch setting to console.
89
90 Args:
91 pitch: Pitch setting (logged but not used)
92 """
93 if not self._is_initialized:
94 return
95 print("Speech Debug Driver: set_pitch:" + str(pitch))
96
97 def set_rate(self, rate):
98 """Log rate setting to console.
99
100 Args:
101 rate: Rate setting (logged but not used)
102 """
103 if not self._is_initialized:
104 return
105 print("Speech Debug Driver: set_rate:" + str(rate))
106
107 def set_module(self, module):
108 """Log module setting to console.
109
110 Args:
111 module: Module setting (logged but not used)
112 """
113 if not self._is_initialized:
114 return
115 print("Speech Debug Driver: set_module:" + str(module))
116
117 def set_language(self, language):
118 """Log language setting to console.
119
120 Args:
121 language: Language setting (logged but not used)
122 """
123 if not self._is_initialized:
124 return
125 print("Speech Debug Driver: set_language:" + str(language))
126
127 def set_volume(self, volume):
128 """Log volume setting to console.
129
130 Args:
131 volume: Volume setting (logged but not used)
132 """
133 if not self._is_initialized:
134 return
135 print("Speech Debug Driver: set_volume:" + str(volume))