2 Commits

Author SHA1 Message Date
7b0797cca1 update readme 2023-10-05 23:49:15 +03:00
482616fb4c Ensure the existence of the temp directory in the binary root 2023-10-05 23:42:04 +03:00
2 changed files with 20 additions and 5 deletions

View File

@ -38,10 +38,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`

View File

@ -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
}