mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
fix: update README links and clean up GetAudioDuration function
This commit is contained in:
parent
e17017eb4a
commit
bfe28fc1f8
@ -71,7 +71,7 @@ You can update the used quota using the API key of any token, allowing other con
|
|||||||
|
|
||||||
### Support OpenAI O1/O1-mini/O1-preview
|
### Support OpenAI O1/O1-mini/O1-preview
|
||||||
|
|
||||||
- [feat: add openai o1](https://github.com/songquanpeng/one-api/pull/1990)
|
- [feat: add openai o1 #1990](https://github.com/songquanpeng/one-api/pull/1990)
|
||||||
|
|
||||||
### Get request's cost
|
### Get request's cost
|
||||||
|
|
||||||
@ -98,4 +98,4 @@ type UserRequestCost struct {
|
|||||||
|
|
||||||
### Whisper's transcription only charges for the length of the input audio
|
### Whisper's transcription only charges for the length of the input audio
|
||||||
|
|
||||||
- [feat(audio): count whisper-1 quota by audio duration](https://github.com/Laisky/one-api/pull/21)
|
- [feat(audio): count whisper-1 quota by audio duration #2022](https://github.com/songquanpeng/one-api/pull/2022)
|
||||||
|
@ -3,7 +3,6 @@ package helper
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -30,13 +29,6 @@ func SaveTmpFile(filename string, data io.Reader) (string, error) {
|
|||||||
|
|
||||||
// GetAudioDuration returns the duration of an audio file in seconds.
|
// GetAudioDuration returns the duration of an audio file in seconds.
|
||||||
func GetAudioDuration(ctx context.Context, filename string) (float64, error) {
|
func GetAudioDuration(ctx context.Context, filename string) (float64, error) {
|
||||||
// print file info for debug
|
|
||||||
fstat, err := os.Stat(filename)
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.Wrap(err, "failed to get audio duration")
|
|
||||||
}
|
|
||||||
fmt.Printf("file name: %s, size: %d\n", filename, fstat.Size())
|
|
||||||
|
|
||||||
// ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {{input}}
|
// ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {{input}}
|
||||||
c := exec.CommandContext(ctx, "/usr/bin/ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", filename)
|
c := exec.CommandContext(ctx, "/usr/bin/ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", filename)
|
||||||
output, err := c.Output()
|
output, err := c.Output()
|
||||||
|
Loading…
Reference in New Issue
Block a user