mirror of
https://github.com/open-webui/open-webui
synced 2025-03-23 06:17:24 +00:00
fix: tts
This commit is contained in:
parent
40ea18d54d
commit
3499ec3f79
@ -199,6 +199,14 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
headers["Authorization"] = f"Bearer {app.state.config.TTS_OPENAI_API_KEY}"
|
headers["Authorization"] = f"Bearer {app.state.config.TTS_OPENAI_API_KEY}"
|
||||||
headers["Content-Type"] = "application/json"
|
headers["Content-Type"] = "application/json"
|
||||||
|
|
||||||
|
try:
|
||||||
|
body = body.decode("utf-8")
|
||||||
|
body = json.loads(body)
|
||||||
|
body["model"] = app.state.config.TTS_MODEL
|
||||||
|
body = json.dumps(body).encode("utf-8")
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
r = None
|
r = None
|
||||||
try:
|
try:
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
|
@ -98,7 +98,7 @@ export const synthesizeOpenAISpeech = async (
|
|||||||
token: string = '',
|
token: string = '',
|
||||||
speaker: string = 'alloy',
|
speaker: string = 'alloy',
|
||||||
text: string = '',
|
text: string = '',
|
||||||
model: string = 'tts-1'
|
model?: string
|
||||||
) => {
|
) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ export const synthesizeOpenAISpeech = async (
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
model: model,
|
|
||||||
input: text,
|
input: text,
|
||||||
voice: speaker
|
voice: speaker,
|
||||||
|
...(model && { model })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
@ -170,8 +170,7 @@
|
|||||||
const res = await synthesizeOpenAISpeech(
|
const res = await synthesizeOpenAISpeech(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
||||||
text,
|
text
|
||||||
$settings?.audio?.tts?.model ?? $config?.audio?.tts?.model
|
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
assistantSpeaking = false;
|
assistantSpeaking = false;
|
||||||
@ -267,8 +266,7 @@
|
|||||||
const res = await synthesizeOpenAISpeech(
|
const res = await synthesizeOpenAISpeech(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
||||||
sentence,
|
sentence
|
||||||
$settings?.audio?.tts?.model ?? $config?.audio?.tts?.model
|
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
|
|
||||||
|
@ -245,8 +245,7 @@
|
|||||||
const res = await synthesizeOpenAISpeech(
|
const res = await synthesizeOpenAISpeech(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
$settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice,
|
||||||
sentence,
|
sentence
|
||||||
$settings?.audio?.tts?.model ?? $config?.audio?.tts?.model
|
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user