Skip to content

Commit

Permalink
fix bugs with voice id not correctly setted
Browse files Browse the repository at this point in the history
  • Loading branch information
daviirodrig committed Mar 7, 2024
1 parent c6049b1 commit dd66b09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions backend/src/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,20 @@ def play_next_str(self, text: str, loop: asyncio.AbstractEventLoop) -> None:
return

logger.info(f"Using {global_config.elevenlabs_buffer_size} elevenlabs buffer size")
voice = Voice(
voice_id=global_config.elevenlabs_voice_id,
settings=VoiceSettings(
stability=global_config.voice_stability, # type: ignore
similarity_boost=global_config.voice_similarity_boost, # type: ignore
style=global_config.voice_style,
),
)
gen = generate(
text=text,
voice=global_config.elevenlabs_voice_id,
voice=voice,
api_key=global_config.elevenlabs_api_key,
stream=global_config.elevenlabs_streaming,
model="eleven_multilingual_v2",
model=global_config.elevenlabs_model, # type: ignore
stream_chunk_size=global_config.elevenlabs_buffer_size,
)
stream_thread = threading.Thread(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mitsuaky.stanleyparable;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.DisplayInfo;
Expand Down Expand Up @@ -458,7 +459,8 @@ public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
if (ClientConfig.SEND_TO_CHAT.get()) {
player.sendSystemMessage(Component.nullToEmpty("Personalidade alterada!"));
}
JsonObject personality = jsonObject.getAsJsonObject("data");
String data = jsonObject.get("data").getAsString();
JsonObject personality = JsonParser.parseString(data).getAsJsonObject();
String voiceID = personality.get("voice_id").getAsString();
ClientConfig.ELEVENLABS_VOICE_ID.set(voiceID);
player.level().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.PLAYER_LEVELUP, SoundSource.MASTER, 1.5F, 1.0F);
Expand Down

0 comments on commit dd66b09

Please sign in to comment.