From d7654ba4e812fb22489095072766e70d12eb8fed Mon Sep 17 00:00:00 2001 From: ArEnSc <6252325+ArEnSc@users.noreply.github.com> Date: Wed, 9 Jul 2025 17:56:34 -0400 Subject: [PATCH] Feature/get set voice url (#236) * add voice data url getter and setter * Ok Voices.js removing types * Match the function style. --- kokoro.js/src/voices.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/kokoro.js/src/voices.js b/kokoro.js/src/voices.js index 0353233..99b78bc 100644 --- a/kokoro.js/src/voices.js +++ b/kokoro.js/src/voices.js @@ -418,7 +418,35 @@ export const VOICES = Object.freeze({ // }, }); -const VOICE_DATA_URL = "https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX/resolve/main/voices"; + +/** + * The base URL for fetching voice data files. + */ +let voiceDataUrl = "https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX/resolve/main/voices"; + + +/** + * Retrieves the current voice data URL. + * + * @returns The current voice data URL. + */ +export function getVoiceDataUrl() { + return voiceDataUrl; +}; + +/** + * Sets a new voice data URL. + * + * @param url - The new URL to set for voice data. + * @throws Will throw an error if the URL is not a valid non-empty string. + */ +export function setVoiceDataUrl(url) { + if (typeof url === 'string' && url.trim() !== '') { + voiceDataUrl = url; + } else { + throw new Error("Invalid URL"); + } +}; /** *