Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ab5dfd8d
authored
Jun 17, 2025
by
chenjm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(audio): :bugs: fix webm audio strconv.ParseFloat: parsing "N/A"
parent
99dacb1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
common/utils.go
+7
-5
relay/channel/openai/relay-openai.go
+1
-0
No files found.
common/utils.go
View file @
ab5dfd8d
...
@@ -263,17 +263,19 @@ func GetAudioDuration(ctx context.Context, filename string, ext string) (float64
...
@@ -263,17 +263,19 @@ func GetAudioDuration(ctx context.Context, filename string, ext string) (float64
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
errors
.
Wrap
(
err
,
"failed to create temporary file"
)
return
0
,
errors
.
Wrap
(
err
,
"failed to create temporary file"
)
}
}
defer
os
.
Remove
(
tmpFp
.
Name
())
tmpName
:=
tmpFp
.
Name
()
defer
tmpFp
.
Close
()
// Close immediately so ffmpeg can open the file on Windows.
_
=
tmpFp
.
Close
()
defer
os
.
Remove
(
tmpName
)
// ffmpeg -y -i filename -vcodec copy -acodec copy
tmpFp
// ffmpeg -y -i filename -vcodec copy -acodec copy
<tmpName>
ffmpegCmd
:=
exec
.
CommandContext
(
ctx
,
"ffmpeg"
,
"-y"
,
"-i"
,
filename
,
"-vcodec"
,
"copy"
,
"-acodec"
,
"copy"
,
tmp
Fp
.
Name
()
)
ffmpegCmd
:=
exec
.
CommandContext
(
ctx
,
"ffmpeg"
,
"-y"
,
"-i"
,
filename
,
"-vcodec"
,
"copy"
,
"-acodec"
,
"copy"
,
tmp
Name
)
if
err
:=
ffmpegCmd
.
Run
();
err
!=
nil
{
if
err
:=
ffmpegCmd
.
Run
();
err
!=
nil
{
return
0
,
errors
.
Wrap
(
err
,
"failed to run ffmpeg"
)
return
0
,
errors
.
Wrap
(
err
,
"failed to run ffmpeg"
)
}
}
// Recalculate the duration of the new file
// Recalculate the duration of the new file
c
=
exec
.
CommandContext
(
ctx
,
"ffprobe"
,
"-v"
,
"error"
,
"-show_entries"
,
"format=duration"
,
"-of"
,
"default=noprint_wrappers=1:nokey=1"
,
tmp
Fp
.
Name
()
)
c
=
exec
.
CommandContext
(
ctx
,
"ffprobe"
,
"-v"
,
"error"
,
"-show_entries"
,
"format=duration"
,
"-of"
,
"default=noprint_wrappers=1:nokey=1"
,
tmp
Name
)
output
,
err
:=
c
.
Output
()
output
,
err
:=
c
.
Output
()
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
errors
.
Wrap
(
err
,
"failed to get audio duration after ffmpeg"
)
return
0
,
errors
.
Wrap
(
err
,
"failed to get audio duration after ffmpeg"
)
...
...
relay/channel/openai/relay-openai.go
View file @
ab5dfd8d
...
@@ -351,6 +351,7 @@ func countAudioTokens(c *gin.Context) (int, error) {
...
@@ -351,6 +351,7 @@ func countAudioTokens(c *gin.Context) (int, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
errors
.
WithStack
(
err
)
return
0
,
errors
.
WithStack
(
err
)
}
}
defer
reqFp
.
Close
()
tmpFp
,
err
:=
os
.
CreateTemp
(
""
,
"audio-*"
+
ext
)
tmpFp
,
err
:=
os
.
CreateTemp
(
""
,
"audio-*"
+
ext
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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