Skip to content

Commit 903c9b4

Browse files
authored
Document that 1-shot TTS is still needed (#2672)
1 parent d1a3ff4 commit 903c9b4

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

docs/core/entity/tts.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@ class MyTextToSpeechEntity(TextToSpeechEntity):
3535
"""Return a list of supported voices for a language."""
3636
```
3737

38-
### Generating TTS audio
38+
### Generating TTS audio in 1-shot
3939

40-
An entity can choose to implement three different ways of generating TTS audio. Only one method can be implemented at a time.
40+
This method takes a message and language as input and returns the TTS audio. It can be implemented as either synchronous or asynchronous and is mandatory to implement.
4141

42-
The stream TTS audio method allows text to be streamed into the TTS service and audio to be streamed back.
42+
```python
43+
class MyTextToSpeechEntity(TextToSpeechEntity):
44+
"""Represent a Text To Speech entity."""
45+
46+
def get_tts_audio(
47+
self, message: str, language: str, options: dict[str, Any]
48+
) -> TtsAudioType:
49+
"""Load tts audio file from the engine."""
50+
51+
async def async_get_tts_audio(
52+
self, message: str, language: str, options: dict[str, Any]
53+
) -> TtsAudioType:
54+
"""Load tts audio file from the engine."""
55+
```
56+
57+
### Generating TTS audio with message streaming in
58+
59+
Large language models generate text in chunks. The TTS service can be called with a stream of text messages, and the TTS service will return the audio in chunks.
60+
61+
This method is optional. When not implemented, the TTS service will call the 1-shot method with the final message.
4362

4463
```python
4564
class MyTextToSpeechEntity(TextToSpeechEntity):
@@ -70,21 +89,3 @@ class TTSAudioResponse:
7089
extension: str
7190
data_gen: AsyncGenerator[bytes]
7291
```
73-
74-
If the Text-to-Speech service requires the entire message to be sent at once, the get tts audio method can be used. It can be implemented as either synchronous or asynchronous.
75-
76-
77-
```python
78-
class MyTextToSpeechEntity(TextToSpeechEntity):
79-
"""Represent a Text To Speech entity."""
80-
81-
def get_tts_audio(
82-
self, message: str, language: str, options: dict[str, Any]
83-
) -> TtsAudioType:
84-
"""Load tts audio file from the engine."""
85-
86-
async def async_get_tts_audio(
87-
self, message: str, language: str, options: dict[str, Any]
88-
) -> TtsAudioType:
89-
"""Load tts audio file from the engine."""
90-
```

0 commit comments

Comments
 (0)