Skip to content

Commit d7654ba

Browse files
authored
Feature/get set voice url (#236)
* add voice data url getter and setter * Ok Voices.js removing types * Match the function style.
1 parent 2760831 commit d7654ba

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

kokoro.js/src/voices.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,35 @@ export const VOICES = Object.freeze({
418418
// },
419419
});
420420

421-
const VOICE_DATA_URL = "https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX/resolve/main/voices";
421+
422+
/**
423+
* The base URL for fetching voice data files.
424+
*/
425+
let voiceDataUrl = "https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX/resolve/main/voices";
426+
427+
428+
/**
429+
* Retrieves the current voice data URL.
430+
*
431+
* @returns The current voice data URL.
432+
*/
433+
export function getVoiceDataUrl() {
434+
return voiceDataUrl;
435+
};
436+
437+
/**
438+
* Sets a new voice data URL.
439+
*
440+
* @param url - The new URL to set for voice data.
441+
* @throws Will throw an error if the URL is not a valid non-empty string.
442+
*/
443+
export function setVoiceDataUrl(url) {
444+
if (typeof url === 'string' && url.trim() !== '') {
445+
voiceDataUrl = url;
446+
} else {
447+
throw new Error("Invalid URL");
448+
}
449+
};
422450

423451
/**
424452
*

0 commit comments

Comments
 (0)