mirror of
https://github.com/mii443/ncb-tts-r2.git
synced 2025-08-22 16:15:29 +00:00
support vec audio
This commit is contained in:
@ -78,7 +78,7 @@ impl TTSMessage for Message {
|
|||||||
res
|
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 text = self.parse(instance, ctx).await;
|
||||||
|
|
||||||
let data_read = ctx.data.read().await;
|
let data_read = ctx.data.read().await;
|
||||||
@ -127,6 +127,6 @@ impl TTSMessage for Message {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
audio
|
vec![audio]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,9 @@ impl TTSInstance {
|
|||||||
let manager = songbird::get(&ctx).await.unwrap();
|
let manager = songbird::get(&ctx).await.unwrap();
|
||||||
let call = manager.get(self.guild).unwrap();
|
let call = manager.get(self.guild).unwrap();
|
||||||
let mut call = call.lock().await;
|
let mut call = call.lock().await;
|
||||||
call.enqueue(audio.into()).await;
|
for audio in audio {
|
||||||
|
call.enqueue(audio.into()).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ pub trait TTSMessage {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// let audio = message.synthesize(instance, ctx).await;
|
/// 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 {
|
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 text = self.parse(instance, ctx).await;
|
||||||
let data_read = ctx.data.read().await;
|
let data_read = ctx.data.read().await;
|
||||||
let storage = data_read
|
let storage = data_read
|
||||||
@ -72,6 +72,6 @@ impl TTSMessage for AnnounceMessage {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
audio
|
vec![audio]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ impl TTS {
|
|||||||
|
|
||||||
if let Some(audio) = self.cache.get(&cache_key) {
|
if let Some(audio) = self.cache.get(&cache_key) {
|
||||||
info!("Cache hit for VOICEVOX TTS");
|
info!("Cache hit for VOICEVOX TTS");
|
||||||
return Ok(audio.clone());
|
return Ok(audio.new_handle());
|
||||||
}
|
}
|
||||||
info!("Cache miss for VOICEVOX TTS");
|
info!("Cache miss for VOICEVOX TTS");
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ impl TTS {
|
|||||||
|
|
||||||
if let Some(audio) = self.cache.get(&cache_key) {
|
if let Some(audio) = self.cache.get(&cache_key) {
|
||||||
info!("Cache hit for GCP TTS");
|
info!("Cache hit for GCP TTS");
|
||||||
return Ok(audio.clone());
|
return Ok(audio.new_handle());
|
||||||
}
|
}
|
||||||
info!("Cache miss for GCP TTS");
|
info!("Cache miss for GCP TTS");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user