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

support mod_rimelabs_tts #425

Merged
merged 1 commit into from
Apr 12, 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
7 changes: 7 additions & 0 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
LimitUnitOption,
PasswordSettings,
PlayHTOptions,
RimelabsOptions,
SelectorOptions,
SipGateway,
SmppGateway,
Expand Down Expand Up @@ -222,6 +223,12 @@ export const DEFAULT_ELEVENLABS_OPTIONS: Partial<ElevenLabsOptions> = {
},
};

// Rimelabs options
export const DEFAULT_RIMELABS_OPTIONS: Partial<RimelabsOptions> = {
speedAlpha: 1.0,
reduceLatency: true,
};

// PlayHT options
export const DEFAULT_PLAYHT_OPTIONS: Partial<PlayHTOptions> = {
quality: "medium",
Expand Down
5 changes: 5 additions & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,3 +731,8 @@ export interface PlayHTOptions {
style_guidance: number;
text_guidance: number;
}

export interface RimelabsOptions {
speedAlpha: number;
reduceLatency: boolean;
}
33 changes: 24 additions & 9 deletions src/containers/internal/views/speech-services/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
VENDOR_ASSEMBLYAI,
VENDOR_WHISPER,
VENDOR_PLAYHT,
VENDOR_RIMELABS,
} from "src/vendor";
import { MSG_REQUIRED_FIELDS } from "src/constants";
import {
Expand Down Expand Up @@ -71,6 +72,7 @@ import {
DEFAULT_ELEVENLABS_OPTIONS,
DEFAULT_GOOGLE_CUSTOM_VOICES_REPORTED_USAGE,
DEFAULT_PLAYHT_OPTIONS,
DEFAULT_RIMELABS_OPTIONS,
DISABLE_CUSTOM_SPEECH,
GOOGLE_CUSTOM_VOICES_REPORTED_USAGE,
} from "src/api/constants";
Expand Down Expand Up @@ -189,6 +191,8 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
return DEFAULT_ELEVENLABS_OPTIONS;
case VENDOR_PLAYHT:
return DEFAULT_PLAYHT_OPTIONS;
case VENDOR_RIMELABS:
return DEFAULT_RIMELABS_OPTIONS;
}
}
return "";
Expand All @@ -201,6 +205,8 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
return "https://elevenlabs.io/docs/api-reference/streaming";
case VENDOR_PLAYHT:
return "https://docs.play.ht/reference/api-generate-tts-audio-stream";
case VENDOR_RIMELABS:
return "https://rimelabs.mintlify.app/api-reference/endpoint/streaming-mp3#variable-parameters";
}
}
return "";
Expand Down Expand Up @@ -321,10 +327,14 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
...(vendor === VENDOR_COBALT && {
cobalt_server_uri: cobaltServerUri || null,
}),
...((vendor === VENDOR_ELEVENLABS || vendor === VENDOR_WHISPER) && {
...((vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_WHISPER ||
vendor === VENDOR_RIMELABS) && {
model_id: ttsModelId || null,
}),
...((vendor === VENDOR_ELEVENLABS || vendor === VENDOR_PLAYHT) && {
...((vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_PLAYHT ||
vendor === VENDOR_RIMELABS) && {
options: options || null,
}),
...(vendor === VENDOR_PLAYHT &&
Expand Down Expand Up @@ -377,6 +387,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
vendor === VENDOR_SONIOX ||
vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_PLAYHT ||
vendor === VENDOR_RIMELABS ||
vendor === VENDOR_WHISPER
? apiKey
: null,
Expand Down Expand Up @@ -418,7 +429,8 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
if (
vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_WHISPER ||
vendor === VENDOR_PLAYHT
vendor === VENDOR_PLAYHT ||
vendor === VENDOR_RIMELABS
) {
getSpeechSupportedLanguagesAndVoices(
currentServiceProvider?.service_provider_sid,
Expand All @@ -429,10 +441,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
setTtsModels(json.models);
if (
json.models.length > 0 &&
!json.models.find((m) => m.value === ttsModelId) &&
(vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_WHISPER ||
vendor === VENDOR_PLAYHT)
!json.models.find((m) => m.value === ttsModelId)
) {
setTtsModelId(json.models[0].value);
}
Expand Down Expand Up @@ -744,6 +753,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
vendor !== VENDOR_CUSTOM &&
vendor !== VENDOR_WHISPER &&
vendor !== VENDOR_PLAYHT &&
vendor !== VENDOR_RIMELABS &&
vendor !== VENDOR_ELEVENLABS && (
<label htmlFor="use_for_stt" className="chk">
<input
Expand Down Expand Up @@ -1191,6 +1201,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
vendor == VENDOR_ELEVENLABS ||
vendor === VENDOR_WHISPER ||
vendor === VENDOR_PLAYHT ||
vendor === VENDOR_RIMELABS ||
vendor === VENDOR_SONIOX) && (
<fieldset>
{vendor === VENDOR_PLAYHT && (
Expand Down Expand Up @@ -1256,7 +1267,9 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
/>
</fieldset>
)}
{(vendor == VENDOR_ELEVENLABS || vendor == VENDOR_WHISPER) &&
{(vendor == VENDOR_ELEVENLABS ||
vendor == VENDOR_WHISPER ||
vendor == VENDOR_RIMELABS) &&
ttsModels.length > 0 && (
<fieldset>
<label htmlFor={`${vendor}_tts_model_id`}>Model</label>
Expand All @@ -1271,7 +1284,9 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
/>
</fieldset>
)}
{(vendor === VENDOR_ELEVENLABS || vendor === VENDOR_PLAYHT) && (
{(vendor === VENDOR_ELEVENLABS ||
vendor === VENDOR_PLAYHT ||
vendor === VENDOR_RIMELABS) && (
<fieldset>
<Checkzone
hidden
Expand Down
5 changes: 5 additions & 0 deletions src/vendor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const VENDOR_ELEVENLABS = "elevenlabs";
export const VENDOR_ASSEMBLYAI = "assemblyai";
export const VENDOR_WHISPER = "whisper";
export const VENDOR_PLAYHT = "playht";
export const VENDOR_RIMELABS = "rimelabs";

export const vendors: VendorOptions[] = [
{
Expand Down Expand Up @@ -83,6 +84,10 @@ export const vendors: VendorOptions[] = [
name: "PlayHT",
value: VENDOR_PLAYHT,
},
{
name: "RimeLabs",
value: VENDOR_RIMELABS,
},
].sort((a, b) => a.name.localeCompare(b.name)) as VendorOptions[];

export const useRegionVendors = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/vendor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export type Vendor =
| "ElevenLabs"
| "assemblyai"
| "whisper"
| "playht";
| "playht"
| "rimelabs";

export interface VendorOptions {
name: Vendor;
Expand Down
Loading