feat: fix sound size
This commit is contained in:
parent
47aaf81e2d
commit
7e6ad370f4
3 changed files with 22 additions and 9 deletions
|
|
@ -48,7 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||
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)?;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,20 @@ class VoiceQueue {
|
|||
return ((connection as any).queue ??= new VoiceQueue(connection));
|
||||
}
|
||||
private play() {
|
||||
try {
|
||||
if (!this.list[0]) return;
|
||||
const player = (this.currentPlayer = createAudioPlayer());
|
||||
this.connection.subscribe(player);
|
||||
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() {
|
||||
try {
|
||||
this.currentPlayer?.removeAllListeners(AudioPlayerStatus.Idle);
|
||||
} catch (err) {
|
||||
console.log(`VoiceQueue next listener remove failed: ${err}`);
|
||||
}
|
||||
this.list.shift();
|
||||
this.play();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue