support vec audio

This commit is contained in:
mii443
2025-04-04 21:46:32 +09:00
parent 82e3c55fd5
commit 696954395b
4 changed files with 10 additions and 8 deletions

View File

@ -78,7 +78,7 @@ impl TTSMessage for Message {
res
}
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Compressed {
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Compressed> {
let text = self.parse(instance, ctx).await;
let data_read = ctx.data.read().await;
@ -127,6 +127,6 @@ impl TTSMessage for Message {
.unwrap(),
};
audio
vec![audio]
}
}

View File

@ -32,9 +32,11 @@ impl TTSInstance {
let manager = songbird::get(&ctx).await.unwrap();
let call = manager.get(self.guild).unwrap();
let mut call = call.lock().await;
for audio in audio {
call.enqueue(audio.into()).await;
}
}
}
pub async fn skip(&mut self, ctx: &Context) {
let manager = songbird::get(&ctx).await.unwrap();

View File

@ -26,7 +26,7 @@ pub trait TTSMessage {
/// ```rust
/// let audio = message.synthesize(instance, ctx).await;
/// ```
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Compressed;
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Compressed>;
}
pub struct AnnounceMessage {
@ -43,7 +43,7 @@ impl TTSMessage for AnnounceMessage {
)
}
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Compressed {
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Compressed> {
let text = self.parse(instance, ctx).await;
let data_read = ctx.data.read().await;
let storage = data_read
@ -72,6 +72,6 @@ impl TTSMessage for AnnounceMessage {
.await
.unwrap();
audio
vec![audio]
}
}

View File

@ -35,7 +35,7 @@ impl TTS {
if let Some(audio) = self.cache.get(&cache_key) {
info!("Cache hit for VOICEVOX TTS");
return Ok(audio.clone());
return Ok(audio.new_handle());
}
info!("Cache miss for VOICEVOX TTS");
@ -58,7 +58,7 @@ impl TTS {
if let Some(audio) = self.cache.get(&cache_key) {
info!("Cache hit for GCP TTS");
return Ok(audio.clone());
return Ok(audio.new_handle());
}
info!("Cache miss for GCP TTS");