Skip to content

Commit 1b6598d

Browse files
committed
lint + test fixes
1 parent fd8bf79 commit 1b6598d

File tree

35 files changed

+284
-304
lines changed

35 files changed

+284
-304
lines changed

test/tts/components-rust/test-tts/src/lib.rs

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Guest for Component {
171171
Ok(result) => {
172172
trace!("Recived result: {:?}", result.metadata);
173173
let dir = "/test-audio-files";
174-
let name = "test4-without-options.mp3";
174+
let name = "test3-without-options.mp3";
175175
let storage_msg = save_audio(&result.audio_data, dir, name);
176176
push_result(&mut test_result, result, test_name, format!("{dir}/{name}"));
177177
test_result.push_str(&format!("\n{}\n", storage_msg));
@@ -232,7 +232,7 @@ impl Guest for Component {
232232
Ok(result) => {
233233
trace!("Recived result: {:?}", result.metadata);
234234
let dir = "/test-audio-files";
235-
let name = "test5-ssml.mp3";
235+
let name = "test4-ssml.mp3";
236236
let storage_msg = save_audio(&result.audio_data, dir, name);
237237
push_result(&mut test_result, result, test_name, format!("{dir}/{name}"));
238238
test_result.push_str(&format!("\n{}\n", storage_msg));
@@ -303,7 +303,7 @@ impl Guest for Component {
303303
for result in batch {
304304
trace!("#{index} Recived result: {:?} ", result.metadata);
305305
let dir = "/test-audio-files";
306-
let name = format!("test6-batch-{}.mp3", index);
306+
let name = format!("test5-batch-{}.mp3", index);
307307
let storage_msg = save_audio(&result.audio_data, dir, &name);
308308
test_result.push_str(&format!("Batch Item #{index}: "));
309309
push_result(&mut test_result, result, test_name, format!("{dir}/{name}"));
@@ -498,7 +498,7 @@ impl Guest for Component {
498498
));
499499

500500
let dir = "/test-audio-files";
501-
let name = "test10-voice-conversion.mp3";
501+
let name = "test7-voice-conversion.mp3";
502502
let storage_msg = save_audio(&converted_audio, dir, name);
503503
test_result.push_str(&format!("💾 Audio saved at {dir}/{name} "));
504504
test_result.push_str(&format!("\n{}\n", storage_msg));
@@ -528,7 +528,7 @@ impl Guest for Component {
528528
));
529529

530530
let dir = "/test-audio-files";
531-
let name = "test10-sound-effect.mp3";
531+
let name = "test7-sound-effect.mp3";
532532
let storage_msg = save_audio(&sound_effect, dir, name);
533533
test_result.push_str(&format!("💾 Audio saved at {dir}/{name}\n"));
534534
test_result.push_str(&format!("{}\n", storage_msg));
@@ -560,37 +560,21 @@ impl Guest for Component {
560560

561561
let long_content = format!("{}\n\n{}\n\n{}", TEXT, TEXT, TEXT);
562562

563-
// For AWS Polly, output_location must be an S3 location (s3://bucket/key)
564-
// For other providers, it can be a local path
565-
#[cfg(feature = "polly")]
566-
let output_location = {
567-
match std::env::var("AWS_S3_BUCKET") {
568-
Ok(bucket) => format!("s3://{}/test-audio-files/test11-long-form", bucket),
569-
Err(_) => {
570-
test_result.push_str(&format!("{test_name} ❌\n"));
571-
test_result.push_str("ERROR : Missing required environment variable AWS_S3_BUCKET for AWS Polly long-form synthesis\n");
572-
return test_result;
573-
}
574-
}
575-
};
576-
577-
#[cfg(not(feature = "polly"))]
578-
let output_location = "/test-audio-files/test11-long-form.mp3";
579-
580563
let chapter_breaks = [0, TEXT.len() as u32, (TEXT.len() * 2) as u32];
581564

582-
match synthesize_long_form(
583-
&long_content,
584-
&voice,
585-
&output_location,
586-
Some(&chapter_breaks),
587-
) {
565+
match synthesize_long_form(&long_content, &voice, Some(&chapter_breaks)) {
588566
Ok(operation) => {
589567
// Monitor the operation progress
590568
let mut attempts = 0;
591569
let max_attempts = 30;
592570

593571
while attempts < max_attempts {
572+
if attempts == 3 {
573+
// Simulate crash
574+
let agent_name = std::env::var("GOLEM_WORKER_NAME").unwrap();
575+
mimic_crash(&agent_name);
576+
}
577+
594578
let status = operation.get_status();
595579
let progress: f32 = operation.get_progress();
596580
trace!(
@@ -740,13 +724,6 @@ impl Guest for Component {
740724

741725
// Test pronunciation lexicons
742726
fn test9() -> String {
743-
let voice = match get_voice(VOICE_UUID) {
744-
Ok(voices) => voices,
745-
Err(err) => {
746-
return format!("❌ ERROR : {:?}", err);
747-
}
748-
};
749-
750727
let mut test_result = String::new();
751728
test_result.push_str("Test pronunciation lexicons summary:\n");
752729

@@ -805,6 +782,10 @@ impl Guest for Component {
805782
trace!("Exporting lexicon content...");
806783
let test3_name = "3. Test export lexicon";
807784

785+
// Simulate crash
786+
let agent_name = std::env::var("GOLEM_WORKER_NAME").unwrap();
787+
mimic_crash(&agent_name);
788+
808789
match lexicon.export_content() {
809790
Ok(content) => {
810791
trace!(

test/tts/wit/deps/golem-tts/golem-tts.wit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ interface advanced {
364364
synthesize-long-form: func(
365365
content: string,
366366
voice: voice,
367-
output-location: string,
368367
chapter-breaks: option<list<u32>>
369368
) -> result<long-form-operation, tts-error>;
370369

tts/deepgram/src/bindings.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
4-
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::types"
54
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::synthesis"
65
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::advanced"
6+
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::types"
77
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::voices"
88
// * generate_unused_types
99
use golem_tts::golem::tts::types as __with_name0;
@@ -16,8 +16,8 @@ use golem_tts::golem::tts::advanced as __with_name3;
1616
)]
1717
#[doc(hidden)]
1818
#[allow(clippy::octal_escapes)]
19-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4808] = *b"\
20-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc6$\x01A\x02\x01A\x13\
19+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4791] = *b"\
20+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb5$\x01A\x02\x01A\x13\
2121
\x01B&\x01m\x04\x0acharacters\x08requests\x07seconds\x07credits\x04\0\x0aquota-u\
2222
nit\x03\0\0\x01r\x04\x04usedy\x05limity\x0areset-timew\x04unit\x01\x04\0\x0aquot\
2323
a-info\x03\0\x02\x01q\x15\x0drequest-error\x01s\0\x0cinvalid-text\x01s\0\x0dtext\
@@ -110,11 +110,11 @@ arget-voice\x0b\x0fpreserve-timing3\04\x04\0\x0dconvert-voice\x015\x01kv\x01@\x0
110110
\x0bdescriptions\x10duration-seconds6\x0fstyle-influence6\04\x04\0\x15generate-s\
111111
ound-effect\x017\x01p\x18\x01k8\x01i\x16\x01j\x01:\x01\x01\x01@\x03\x04names\x08\
112112
language\x05\x07entries9\0;\x04\0\x0ecreate-lexicon\x01<\x01py\x01k=\x01i\x19\x01\
113-
j\x01?\x01\x01\x01@\x04\x07contents\x05voice\x0b\x0foutput-locations\x0echapter-\
114-
breaks>\0\xc0\0\x04\0\x14synthesize-long-form\x01A\x04\0\x18golem:tts/advanced@1\
115-
.0.0\x05\x0e\x04\0$golem:tts-deepgram/[email protected]\x04\0\x0b\x11\x01\0\x0bt\
116-
ts-library\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070\
117-
.227.1\x10wit-bindgen-rust\x060.41.0";
113+
j\x01?\x01\x01\x01@\x03\x07contents\x05voice\x0b\x0echapter-breaks>\0\xc0\0\x04\0\
114+
\x14synthesize-long-form\x01A\x04\0\x18golem:tts/advanced@1.0.0\x05\x0e\x04\0$go\
115+
lem:tts-deepgram/[email protected]\x04\0\x0b\x11\x01\0\x0btts-library\x03\0\0\0G\
116+
\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen\
117+
-rust\x060.41.0";
118118
#[inline(never)]
119119
#[doc(hidden)]
120120
pub fn __link_custom_section_describing_imports() {

tts/deepgram/src/deepgram.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use golem_tts::{
22
client::{ApiClient, TtsClient},
33
config::get_env,
44
golem::tts::{
5-
advanced::{
6-
AudioSample, LanguageCode, PronunciationEntry, PronunciationLexicon, Voice,
7-
VoiceDesignParams,
8-
},
5+
advanced::{AudioSample, LanguageCode, PronunciationEntry, Voice, VoiceDesignParams},
96
synthesis::{SynthesisOptions, TextInput, TimingInfo, ValidationResult},
107
types::{SynthesisMetadata, SynthesisResult, TextType, TtsError, VoiceGender},
118
voices::{LanguageInfo, VoiceFilter},
@@ -17,10 +14,7 @@ use serde::{Deserialize, Serialize};
1714

1815
use crate::{
1916
error::{from_http_error, unsupported},
20-
resources::{
21-
DeepgramLongFormOperation, DeepgramPronunciationLexicon,
22-
VoiceResponse,
23-
},
17+
resources::{DeepgramLongFormOperation, DeepgramPronunciationLexicon, VoiceResponse},
2418
utils::estimate_duration,
2519
};
2620

@@ -62,7 +56,7 @@ impl TtsClient for Deepgram {
6256
.map(|ac| ac.format.clone());
6357

6458
// Deepgram doesn't allow sample_rate with MP3 encoding
65-
let sample_rate = if encoding.as_ref().map(|e| e.as_str()) == Some("mp3") {
59+
let sample_rate = if encoding.as_deref() == Some("mp3") {
6660
None
6761
} else {
6862
options
@@ -359,7 +353,6 @@ impl TtsClient for Deepgram {
359353
&self,
360354
_content: String,
361355
_voice: String,
362-
_output_location: String,
363356
_chapter_breaks: Option<Vec<u32>>,
364357
) -> Result<Self::ClientLongFormOperation, TtsError> {
365358
unsupported("Deepgram does not supported Async synthesis.")

tts/deepgram/src/lib.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use golem_tts::{
66
AudioSample, Guest as AdvancedGuest, LanguageCode, LongFormOperation,
77
PronunciationEntry, PronunciationLexicon, TtsError, Voice, VoiceDesignParams,
88
},
9-
synthesis::{Guest as SynthesisGuest, SynthesisOptions, SynthesisResult, TextInput, TimingInfo, ValidationResult},
9+
synthesis::{
10+
Guest as SynthesisGuest, SynthesisOptions, SynthesisResult, TextInput, TimingInfo,
11+
ValidationResult,
12+
},
1013
voices::{Guest as VoicesGuest, LanguageInfo, VoiceFilter},
1114
},
1215
};
@@ -120,13 +123,15 @@ impl AdvancedGuest for DeepgramComponent {
120123
fn synthesize_long_form(
121124
content: String,
122125
voice: Voice,
123-
output_location: String,
124126
chapter_breaks: Option<Vec<u32>>,
125127
) -> Result<LongFormOperation, TtsError> {
126128
let deepgram = Deepgram::new()?;
127129
let voice_canonical_name = voice.name.clone(); // Use canonical name
128-
let operation =
129-
deepgram.synthesize_long_form(content, voice_canonical_name, output_location, chapter_breaks)?;
130+
let operation = deepgram.synthesize_long_form(
131+
content,
132+
voice_canonical_name,
133+
chapter_breaks,
134+
)?;
130135
Ok(LongFormOperation::new(operation))
131136
}
132137
}
@@ -157,25 +162,25 @@ impl ExtendedAdvancedTrait for DeepgramComponent {
157162
language: LanguageCode,
158163
entries: Option<Vec<PronunciationEntry>>,
159164
) -> Result<Self::PronunciationLexicon, golem_tts::golem::tts::types::TtsError> {
160-
let client = Deepgram::new()?;
165+
let client = Deepgram::new()?;
161166
client.create_lexicon(name, language, entries)
162167
}
163168

164169
fn unwrappered_synthesize_long_form(
165170
content: String,
166171
voice: Voice,
167-
output_location: String,
168172
chapter_breaks: Option<Vec<u32>>,
169173
) -> Result<Self::LongFormOperation, golem_tts::golem::tts::types::TtsError> {
170174
let client = Deepgram::new()?;
171175
let voice_canonical_name = voice.name.clone(); // Use canonical name
172-
client.synthesize_long_form(content, voice_canonical_name, output_location, chapter_breaks)
176+
client.synthesize_long_form(
177+
content,
178+
voice_canonical_name,
179+
chapter_breaks,
180+
)
173181
}
174182
}
175183

176-
177-
178-
179184
type DurableDeepgramComponent = DurableTTS<DeepgramComponent>;
180185

181186
golem_tts::export_tts!(DurableDeepgramComponent with_types_in golem_tts);

tts/deepgram/src/resources.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use golem_rust::{FromValueAndType, IntoValue};
12
use golem_tts::golem::tts::advanced::{
2-
GuestLongFormOperation, GuestPronunciationLexicon, LanguageCode, LongFormResult, OperationStatus,
3-
TtsError, Voice,
3+
GuestLongFormOperation, GuestPronunciationLexicon, LanguageCode, LongFormResult,
4+
OperationStatus, TtsError,
45
};
5-
use golem_rust::{FromValueAndType, IntoValue};
66
use serde::{Deserialize, Serialize};
77

88
use crate::error::unsupported;
@@ -31,8 +31,6 @@ pub struct DeepgramVoiceMetadata {
3131
pub use_cases: Vec<String>,
3232
}
3333

34-
35-
3634
pub struct DeepgramPronunciationLexicon;
3735

3836
impl GuestPronunciationLexicon for DeepgramPronunciationLexicon {

tts/deepgram/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use golem_tts::golem::tts::{types::VoiceGender, voices::Voice, };
1+
use golem_tts::golem::tts::{types::VoiceGender, voices::Voice};
22

33
use crate::resources::VoiceResponse;
44

@@ -26,7 +26,7 @@ impl From<&VoiceResponse> for Voice {
2626
}
2727

2828
Voice {
29-
id: v.uuid.clone(), // Keep UUID for get_voice API
29+
id: v.uuid.clone(), // Keep UUID for get_voice API
3030
name: v.canonical_name.clone(), // Use canonical_name for synthesis
3131
language: v.languages[0].clone(),
3232
additional_languages: v.languages.clone(),

tts/deepgram/wit/deps/golem-tts/golem-tts.wit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ interface advanced {
364364
synthesize-long-form: func(
365365
content: string,
366366
voice: voice,
367-
output-location: string,
368367
chapter-breaks: option<list<u32>>
369368
) -> result<long-form-operation, tts-error>;
370369

tts/elevenlabs/src/bindings.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
4-
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::synthesis"
5-
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::advanced"
64
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::types"
75
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::voices"
6+
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::advanced"
7+
// * with "golem:tts/[email protected]" = "golem_tts::golem::tts::synthesis"
88
// * generate_unused_types
99
use golem_tts::golem::tts::types as __with_name0;
1010
use golem_tts::golem::tts::voices as __with_name1;
@@ -16,8 +16,8 @@ use golem_tts::golem::tts::advanced as __with_name3;
1616
)]
1717
#[doc(hidden)]
1818
#[allow(clippy::octal_escapes)]
19-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4810] = *b"\
20-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc8$\x01A\x02\x01A\x13\
19+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4793] = *b"\
20+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb7$\x01A\x02\x01A\x13\
2121
\x01B&\x01m\x04\x0acharacters\x08requests\x07seconds\x07credits\x04\0\x0aquota-u\
2222
nit\x03\0\0\x01r\x04\x04usedy\x05limity\x0areset-timew\x04unit\x01\x04\0\x0aquot\
2323
a-info\x03\0\x02\x01q\x15\x0drequest-error\x01s\0\x0cinvalid-text\x01s\0\x0dtext\
@@ -110,11 +110,11 @@ arget-voice\x0b\x0fpreserve-timing3\04\x04\0\x0dconvert-voice\x015\x01kv\x01@\x0
110110
\x0bdescriptions\x10duration-seconds6\x0fstyle-influence6\04\x04\0\x15generate-s\
111111
ound-effect\x017\x01p\x18\x01k8\x01i\x16\x01j\x01:\x01\x01\x01@\x03\x04names\x08\
112112
language\x05\x07entries9\0;\x04\0\x0ecreate-lexicon\x01<\x01py\x01k=\x01i\x19\x01\
113-
j\x01?\x01\x01\x01@\x04\x07contents\x05voice\x0b\x0foutput-locations\x0echapter-\
114-
breaks>\0\xc0\0\x04\0\x14synthesize-long-form\x01A\x04\0\x18golem:tts/advanced@1\
115-
.0.0\x05\x0e\x04\0&golem:tts-elevenlabs/[email protected]\x04\0\x0b\x11\x01\0\x0b\
116-
tts-library\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x07\
117-
0.227.1\x10wit-bindgen-rust\x060.41.0";
113+
j\x01?\x01\x01\x01@\x03\x07contents\x05voice\x0b\x0echapter-breaks>\0\xc0\0\x04\0\
114+
\x14synthesize-long-form\x01A\x04\0\x18golem:tts/advanced@1.0.0\x05\x0e\x04\0&go\
115+
lem:tts-elevenlabs/[email protected]\x04\0\x0b\x11\x01\0\x0btts-library\x03\0\0\0\
116+
G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindge\
117+
n-rust\x060.41.0";
118118
#[inline(never)]
119119
#[doc(hidden)]
120120
pub fn __link_custom_section_describing_imports() {

tts/elevenlabs/src/elevenlabs.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use golem_tts::{
55
config::get_env,
66
golem::tts::{
77
advanced::{
8-
AgeCategory, AudioSample, LanguageCode, PronunciationEntry, PronunciationLexicon,
9-
Voice, VoiceDesignParams,
8+
AgeCategory, AudioSample, LanguageCode, PronunciationEntry, Voice, VoiceDesignParams,
109
},
1110
synthesis::{SynthesisOptions, SynthesisResult, TextInput, TimingInfo, ValidationResult},
1211
types::{SynthesisMetadata, TextType, TtsError, VoiceGender},
@@ -35,10 +34,7 @@ pub struct Elevenlabs {
3534
base_url: String,
3635
}
3736

38-
39-
4037
impl TtsClient for Elevenlabs {
41-
4238
type ClientLongFormOperation = ElLongFormSynthesis;
4339
type ClientPronunciationLexicon = ElPronunciationLexicon;
4440

@@ -847,7 +843,6 @@ impl TtsClient for Elevenlabs {
847843
&self,
848844
_content: String,
849845
_voice: String,
850-
_output_location: String,
851846
_chapter_breaks: Option<Vec<u32>>,
852847
) -> Result<ElLongFormSynthesis, TtsError> {
853848
unsupported("Long-form synthesis not yet implemented for ElevenLabs TTS")

0 commit comments

Comments
 (0)