Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
3499ec3f
Commit
3499ec3f
authored
Jun 08, 2024
by
Timothy J. Baek
Browse files
fix: tts
parent
40ea18d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
9 deletions
+14
-9
backend/apps/audio/main.py
backend/apps/audio/main.py
+8
-0
src/lib/apis/audio/index.ts
src/lib/apis/audio/index.ts
+3
-3
src/lib/components/chat/MessageInput/CallOverlay.svelte
src/lib/components/chat/MessageInput/CallOverlay.svelte
+2
-4
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+1
-2
No files found.
backend/apps/audio/main.py
View file @
3499ec3f
...
@@ -199,6 +199,14 @@ async def speech(request: Request, user=Depends(get_verified_user)):
...
@@ -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
(
...
...
src/lib/apis/audio/index.ts
View file @
3499ec3f
...
@@ -98,7 +98,7 @@ export const synthesizeOpenAISpeech = async (
...
@@ -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 (
...
@@ -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
)
=>
{
...
...
src/lib/components/chat/MessageInput/CallOverlay.svelte
View file @
3499ec3f
...
@@ -170,8 +170,7 @@
...
@@ -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 @@
...
@@ -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);
...
...
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
3499ec3f
...
@@ -245,8 +245,7 @@
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment