-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from flukexp/support-piper
added support for piper tts server
- Loading branch information
Showing
7 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { BasicPage, FormRow, NotUsingAlert } from './common'; | ||
import { TextInput } from "@/components/textInput"; | ||
import { config, updateConfig } from "@/utils/config"; | ||
|
||
export function PiperSettingsPage({ | ||
piperUrl, | ||
setPiperUrl, | ||
setSettingsUpdated, | ||
}: { | ||
piperUrl: string; | ||
setPiperUrl: (key: string) => void; | ||
setSettingsUpdated: (updated: boolean) => void; | ||
}) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<BasicPage | ||
title={t("Piper") + " " + t("Settings")} | ||
description={t("piper_desc", "Configure Piper")} | ||
> | ||
{config("tts_backend") !== "piper" && ( | ||
<NotUsingAlert> | ||
{t("not_using_alert", "You are not currently using {{name}} as your {{what}} backend. These settings will not be used.", { name: t("Piper"), what: t("TTS") })} | ||
</NotUsingAlert> | ||
)} | ||
<ul role="list" className="divide-y divide-gray-100 max-w-xs"> | ||
<li className="py-4"> | ||
<FormRow label={t("URL")}> | ||
<TextInput | ||
value={piperUrl} | ||
onChange={(event: React.ChangeEvent<any>) => { | ||
setPiperUrl(event.target.value); | ||
updateConfig("piper_url", event.target.value); | ||
setSettingsUpdated(true); | ||
}} | ||
/> | ||
</FormRow> | ||
</li> | ||
</ul> | ||
</BasicPage> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { config } from '@/utils/config'; | ||
|
||
export async function piper( | ||
message: string, | ||
) { | ||
try { | ||
|
||
const url = new URL(config("piper_url")); | ||
url.searchParams.append('text', message); | ||
|
||
const res = await fetch(url.toString()); | ||
|
||
const data = (await res.arrayBuffer()) as any; | ||
return { audio: data }; | ||
} catch (error) { | ||
|
||
console.error('Error in piper:', error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters