mirror of
https://github.com/xzeldon/whisper-api-server.git
synced 2025-07-12 23:04:36 +03:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
dde206facd | |||
2e92dd91cb | |||
dacad9a4f6
|
|||
7d6be4b7d3
|
|||
7b0797cca1
|
|||
482616fb4c
|
21
README.md
21
README.md
@ -11,6 +11,20 @@ This API server enables audio transcription using the OpenAI Whisper models.
|
||||
|
||||
# Build from source
|
||||
|
||||
Before build make sure that **CGO_ENABLED** env is set to **1**
|
||||
|
||||
```
|
||||
set CGO_ENABLED 1
|
||||
```
|
||||
|
||||
or preferable set it parament. Then check it via
|
||||
|
||||
```
|
||||
go env
|
||||
```
|
||||
|
||||
Also you have to have installed gcc x64 i.e. by MYSYS
|
||||
|
||||
Download the sources and use `go build`.
|
||||
For example, you can build using the following command:
|
||||
|
||||
@ -38,10 +52,9 @@ Receive a response in JSON format:
|
||||
|
||||
# Usage with [Obsidian](https://obsidian.md/)
|
||||
|
||||
To integrate this with the [Obsidian voice recognotion plugin](https://github.com/nikdanilov/whisper-obsidian-plugin), follow these steps:
|
||||
|
||||
1. Open the plugin's settings.
|
||||
2. Set the following values:
|
||||
1. Install [Obsidian voice recognotion plugin](https://github.com/nikdanilov/whisper-obsidian-plugin)
|
||||
2. Open the plugin's settings.
|
||||
3. Set the following values:
|
||||
- API KEY: `sk-1`
|
||||
- API URL: `http://localhost:3000/v1/audio/transcriptions`
|
||||
- Model: `whisper-1`
|
||||
|
@ -41,9 +41,6 @@ func InitializeWhisperState(modelPath string) (*WhisperState, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params.AddFlags(whisper.FlagNoContext)
|
||||
params.AddFlags(whisper.FlagTokenTimestamps)
|
||||
|
||||
fmt.Printf("Params CPU Threads : %d\n", params.CpuThreads())
|
||||
|
||||
return &WhisperState{
|
||||
|
@ -22,9 +22,14 @@ func saveFormFile(name string, c echo.Context) (string, error) {
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
tmpDir, err := ensureDir("tmp")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ext := filepath.Ext(file.Filename)
|
||||
filename := time.Now().Format(time.RFC3339)
|
||||
filename = "./tmp/" + sanitizeFilename(filename) + ext
|
||||
filename = tmpDir + "/" + sanitizeFilename(filename) + ext
|
||||
|
||||
dst, err := os.Create(filename)
|
||||
if err != nil {
|
||||
@ -46,3 +51,14 @@ func sanitizeFilename(filename string) string {
|
||||
}
|
||||
return filename
|
||||
}
|
||||
|
||||
func ensureDir(dirPath string) (string, error) {
|
||||
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
||||
err := os.MkdirAll(dirPath, 0700)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return dirPath, nil
|
||||
}
|
||||
|
@ -86,6 +86,16 @@ func (this *FullParams) RemoveFlags(newflag eFullParamsFlags) {
|
||||
this.cStruct.Flags = this.cStruct.Flags ^ newflag
|
||||
}
|
||||
|
||||
func (this *FullParams) SetLanguage(language eLanguage) {
|
||||
if this == nil {
|
||||
return
|
||||
} else if this.cStruct == nil {
|
||||
return
|
||||
}
|
||||
|
||||
this.cStruct.Language = language
|
||||
}
|
||||
|
||||
/*using pfnNewSegment = HRESULT( __cdecl* )( iContext* ctx, uint32_t n_new, void* user_data ) noexcept;*/
|
||||
type NewSegmentCallback_Type func(context *IContext, n_new uint32, user_data unsafe.Pointer) EWhisperHWND
|
||||
|
||||
|
Reference in New Issue
Block a user