-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_tts_provider.py
56 lines (40 loc) · 1.35 KB
/
print_tts_provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
from tts_provider import TTSProvider
from byte_queue_file import ByteQueueFile
class PrintTTSProvider(TTSProvider):
def __init__(self):
self.model_names = [ "printer" ]
self.voice = [ "text" ]
def name(self):
return 'printer'
def channels(self):
raise NotImplementedError()
def samplerate(self):
raise NotImplementedError()
def dtype(self):
raise NotImplementedError()
def format(self):
raise NotImplementedError()
def volumegain(self):
raise NotImplementedError()
def blocksize(self):
raise NotImplementedError()
def max_length(self):
return 4096
def default_voice(self):
return self.voice[0]
def default_model(self):
return self.model_names[0]
def _list_models(self):
return self.model_names
def _list_voices(self):
return self.voices
def get_response(self, text, model, voice_id, speed):
pass
def text_to_speech(self, text, model, voice_id, speed, audio_file):
print(f'({len(text)}): {text}')
if audio_file is not None and os.path.exists(audio_file):
os.remove(audio_file)
def text_to_speech_stream(self, text, model, voice_id, speed, virtual_audio_file: ByteQueueFile):
print(f'({len(text)}): {text}')
virtual_audio_file.close()