Enha: show user an error in case stt failed
This commit is contained in:
@@ -1,22 +1,5 @@
|
|||||||
package extra
|
package extra
|
||||||
|
|
||||||
/*
|
|
||||||
#cgo LDFLAGS: -lasound
|
|
||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
|
||||||
|
|
||||||
extern void go_alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...);
|
|
||||||
|
|
||||||
void set_alsa_error_handler() {
|
|
||||||
snd_lib_error_set_handler(go_alsa_error_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void go_alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...) {
|
|
||||||
return; // Complete suppression
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
@@ -49,7 +32,6 @@ type WhisperBinary struct {
|
|||||||
func NewWhisperBinary(logger *slog.Logger, cfg *config.Config) *WhisperBinary {
|
func NewWhisperBinary(logger *slog.Logger, cfg *config.Config) *WhisperBinary {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
// Set ALSA error handler first
|
// Set ALSA error handler first
|
||||||
C.set_alsa_error_handler()
|
|
||||||
return &WhisperBinary{
|
return &WhisperBinary{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
whisperPath: cfg.WhisperBinaryPath,
|
whisperPath: cfg.WhisperBinaryPath,
|
||||||
|
|||||||
4
tui.go
4
tui.go
@@ -823,7 +823,9 @@ func init() {
|
|||||||
if asr.IsRecording() {
|
if asr.IsRecording() {
|
||||||
userSpeech, err := asr.StopRecording()
|
userSpeech, err := asr.StopRecording()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("failed to inference user speech", "error", err)
|
msg := "failed to inference user speech; error:" + err.Error()
|
||||||
|
logger.Error(msg)
|
||||||
|
notifyUser("stt error", msg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if userSpeech != "" {
|
if userSpeech != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user