change type

This commit is contained in:
mii443
2025-04-11 14:03:13 +09:00
parent 771711e3bf
commit 257c8511e3
2 changed files with 14 additions and 14 deletions

View File

@ -1,7 +1,7 @@
use async_trait::async_trait; use async_trait::async_trait;
use regex::Regex; use regex::Regex;
use serenity::{model::prelude::Message, prelude::Context}; use serenity::{model::prelude::Message, prelude::Context};
use songbird::input::cached::Compressed; use songbird::tracks::Track;
use crate::{ use crate::{
data::{DatabaseClientData, TTSClientData}, data::{DatabaseClientData, TTSClientData},
@ -88,7 +88,7 @@ impl TTSMessage for Message {
res res
} }
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Compressed> { async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Track> {
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;
@ -110,8 +110,8 @@ impl TTSMessage for Message {
.get::<TTSClientData>() .get::<TTSClientData>()
.expect("Cannot get GCP TTSClientStorage"); .expect("Cannot get GCP TTSClientStorage");
let audio = match config.tts_type.unwrap_or(TTSType::GCP) { match config.tts_type.unwrap_or(TTSType::GCP) {
TTSType::GCP => tts TTSType::GCP => vec![tts
.synthesize_gcp(SynthesizeRequest { .synthesize_gcp(SynthesizeRequest {
input: SynthesisInput { input: SynthesisInput {
text: None, text: None,
@ -125,17 +125,17 @@ impl TTSMessage for Message {
}, },
}) })
.await .await
.unwrap(), .unwrap()
.into()],
TTSType::VOICEVOX => tts TTSType::VOICEVOX => vec![tts
.synthesize_voicevox( .synthesize_voicevox(
&text.replace("<break time=\"200ms\"/>", ""), &text.replace("<break time=\"200ms\"/>", ""),
config.voicevox_speaker.unwrap_or(1), config.voicevox_speaker.unwrap_or(1),
) )
.await .await
.unwrap(), .unwrap()
}; .into()],
}
vec![audio]
} }
} }

View File

@ -1,6 +1,6 @@
use async_trait::async_trait; use async_trait::async_trait;
use serenity::prelude::Context; use serenity::prelude::Context;
use songbird::input::cached::Compressed; use songbird::tracks::Track;
use crate::{data::TTSClientData, tts::instance::TTSInstance}; use crate::{data::TTSClientData, tts::instance::TTSInstance};
@ -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) -> Vec<Compressed>; async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Track>;
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -44,7 +44,7 @@ impl TTSMessage for AnnounceMessage {
) )
} }
async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Compressed> { async fn synthesize(&self, instance: &mut TTSInstance, ctx: &Context) -> Vec<Track> {
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 tts = data_read let tts = data_read
@ -71,6 +71,6 @@ impl TTSMessage for AnnounceMessage {
.await .await
.unwrap(); .unwrap();
vec![audio] vec![audio.into()]
} }
} }