|
11 | 11 | Package, |
12 | 12 | ReferenceAudio, |
13 | 13 | Prosody, |
| 14 | + TTSConfig, |
| 15 | + TTSRequest, |
14 | 16 | ) |
15 | 17 |
|
16 | 18 |
|
@@ -96,3 +98,84 @@ def test_prosody_custom(self): |
96 | 98 | prosody = Prosody(speed=1.5, volume=0.5) |
97 | 99 | assert prosody.speed == 1.5 |
98 | 100 | assert prosody.volume == 0.5 |
| 101 | + |
| 102 | + def test_tts_config_defaults(self): |
| 103 | + """Test TTSConfig default values including new parameters.""" |
| 104 | + config = TTSConfig() |
| 105 | + # Existing defaults |
| 106 | + assert config.format == "mp3" |
| 107 | + assert config.mp3_bitrate == 128 |
| 108 | + assert config.opus_bitrate == 32 |
| 109 | + assert config.normalize is True |
| 110 | + assert config.chunk_length == 200 |
| 111 | + assert config.latency == "balanced" |
| 112 | + assert config.top_p == 0.7 |
| 113 | + assert config.temperature == 0.7 |
| 114 | + # New parameter defaults |
| 115 | + assert config.max_new_tokens == 1024 |
| 116 | + assert config.repetition_penalty == 1.2 |
| 117 | + assert config.min_chunk_length == 50 |
| 118 | + assert config.condition_on_previous_chunks is True |
| 119 | + assert config.early_stop_threshold == 1.0 |
| 120 | + |
| 121 | + def test_tts_config_custom_new_parameters(self): |
| 122 | + """Test TTSConfig with custom values for new parameters.""" |
| 123 | + config = TTSConfig( |
| 124 | + max_new_tokens=2048, |
| 125 | + repetition_penalty=1.5, |
| 126 | + min_chunk_length=100, |
| 127 | + condition_on_previous_chunks=False, |
| 128 | + early_stop_threshold=0.8, |
| 129 | + ) |
| 130 | + assert config.max_new_tokens == 2048 |
| 131 | + assert config.repetition_penalty == 1.5 |
| 132 | + assert config.min_chunk_length == 100 |
| 133 | + assert config.condition_on_previous_chunks is False |
| 134 | + assert config.early_stop_threshold == 0.8 |
| 135 | + |
| 136 | + def test_tts_request_defaults(self): |
| 137 | + """Test TTSRequest default values including new parameters.""" |
| 138 | + request = TTSRequest(text="Hello world") |
| 139 | + # Existing defaults |
| 140 | + assert request.text == "Hello world" |
| 141 | + assert request.format == "mp3" |
| 142 | + assert request.chunk_length == 200 |
| 143 | + assert request.latency == "balanced" |
| 144 | + # New parameter defaults |
| 145 | + assert request.max_new_tokens == 1024 |
| 146 | + assert request.repetition_penalty == 1.2 |
| 147 | + assert request.min_chunk_length == 50 |
| 148 | + assert request.condition_on_previous_chunks is True |
| 149 | + assert request.early_stop_threshold == 1.0 |
| 150 | + |
| 151 | + def test_tts_request_custom_new_parameters(self): |
| 152 | + """Test TTSRequest with custom values for new parameters.""" |
| 153 | + request = TTSRequest( |
| 154 | + text="Hello world", |
| 155 | + max_new_tokens=512, |
| 156 | + repetition_penalty=1.0, |
| 157 | + min_chunk_length=25, |
| 158 | + condition_on_previous_chunks=False, |
| 159 | + early_stop_threshold=0.5, |
| 160 | + ) |
| 161 | + assert request.max_new_tokens == 512 |
| 162 | + assert request.repetition_penalty == 1.0 |
| 163 | + assert request.min_chunk_length == 25 |
| 164 | + assert request.condition_on_previous_chunks is False |
| 165 | + assert request.early_stop_threshold == 0.5 |
| 166 | + |
| 167 | + |
| 168 | +class TestVoiceStates: |
| 169 | + """Test Voice model with different states and visibility.""" |
| 170 | + |
| 171 | + def test_voice_with_ready_state(self, sample_voice_response): |
| 172 | + """Test Voice model with 'ready' state.""" |
| 173 | + sample_voice_response["state"] = "ready" |
| 174 | + voice = Voice.model_validate(sample_voice_response) |
| 175 | + assert voice.state == "ready" |
| 176 | + |
| 177 | + def test_voice_with_unlisted_visibility(self, sample_voice_response): |
| 178 | + """Test Voice model with 'unlisted' visibility.""" |
| 179 | + sample_voice_response["visibility"] = "unlisted" |
| 180 | + voice = Voice.model_validate(sample_voice_response) |
| 181 | + assert voice.visibility == "unlisted" |
0 commit comments