Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix voice id config not syncing when changed on dashboard #89

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/src/components/tabs/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import gradio as gr
from src.config import global_config
from src.prompts import prompt_manager
Expand Down Expand Up @@ -37,7 +38,8 @@ async def change_personality(personality_id: str, checkboxes: list):
global_config.elevenlabs_model = prompt_manager.personalities[personality_id]["model"]

if notify_minecraft:
await ws.broadcast({"action": "new_personality", "data": personality_id})
data = json.dumps(prompt_manager.personalities[personality_id])
await ws.broadcast({"action": "new_personality", "data": data})

return f"Personality setted to {personality_id}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mitsuaky.stanleyparable;

import com.google.gson.JsonObject;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.DisplayInfo;
Expand Down Expand Up @@ -453,6 +454,11 @@ 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 voiceID = personality.get("voice_id").getAsString();
ClientConfig.ELEVENLABS_VOICE_ID.set(voiceID);

player.level().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.MASTER, 1.0F, 1.0F);
return null;
});
Expand All @@ -461,6 +467,7 @@ public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
String playerName = getPlayerName(player);
wsClient.sendEvent(Event.JOIN_WORLD.getValue(), String.format("Jogador \"%s\" entrou no mundo \"%s\"", playerName, worldName));
}

private enum TimeState {
DAY, SUNSET, NIGHT
}
Expand Down
Loading