diff --git a/crates/yaejuyang-supertonic/src/main.rs b/crates/yaejuyang-supertonic/src/main.rs index 51f7481..cfce68c 100644 --- a/crates/yaejuyang-supertonic/src/main.rs +++ b/crates/yaejuyang-supertonic/src/main.rs @@ -48,7 +48,7 @@ async fn main() -> Result<(), Box> { let sound_size_mul: f32 = std::env::var("SUPERTONIC_SIZE_MUL") .ok() .and_then(|v| v.parse().ok()) - .unwrap_or(1.5); + .unwrap_or(1.0f32); let model_path = PathBuf::from(&model_dir); tts::assets::ensure_assets(&model_path, &hf_repo)?; diff --git a/packages/bot/tts.ts b/packages/bot/tts.ts index 1e55912..513059d 100644 --- a/packages/bot/tts.ts +++ b/packages/bot/tts.ts @@ -28,11 +28,20 @@ class VoiceQueue { return ((connection as any).queue ??= new VoiceQueue(connection)); } private play() { - if (!this.list[0]) return; - const player = (this.currentPlayer = createAudioPlayer()); - this.connection.subscribe(player); - player.once(AudioPlayerStatus.Idle, this.next.bind(this)); - player.play(this.list[0]); + try { + if (!this.list[0]) return; + const player = (this.currentPlayer = createAudioPlayer()); + const sub = this.connection.subscribe(player); + if (!sub) { + this.next(); + return; + } + player.once(AudioPlayerStatus.Idle, this.next.bind(this)); + player.play(this.list[0]); + } catch (err) { + console.error(`VoiceQueue play failed: ${err}`); + this.next(); + } } public enqueue(resource: AudioResource) { this.list.push(resource); @@ -42,7 +51,11 @@ class VoiceQueue { } } public next() { - this.currentPlayer?.removeAllListeners(AudioPlayerStatus.Idle); + try { + this.currentPlayer?.removeAllListeners(AudioPlayerStatus.Idle); + } catch (err) { + console.log(`VoiceQueue next listener remove failed: ${err}`); + } this.list.shift(); this.play(); } diff --git a/packages/tts/index.ts b/packages/tts/index.ts index e2349e2..b765c6d 100644 --- a/packages/tts/index.ts +++ b/packages/tts/index.ts @@ -80,11 +80,11 @@ export namespace TTSModelBase { export function bufferToAudioResource(buf: Buffer): AudioResource { const stream = Readable.from(buf); const resource = createAudioResource(stream, { - inlineVolume: true, + // inlineVolume: true, inputType: StreamType.Arbitrary, }); - resource.volume?.setVolume(0.3); + // resource.volume?.setVolume(0.3); return resource; } export function hashAudioFile(audio: string, suffix: string = ""): string {