Attempt to make audio and speech discovery more robust.
This commit is contained in:
1 parent
a27f274099
commit
dc945ff392
21 files changed
+1314
-60
No files matched your search
@@ -17,7 +17,10 @@
|
||||
|
||||
package speech
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Driver binds a stable file/CLI ID to its implementation. Availability must
|
||||
// be a cheap dependency/hardware check, never connect, speak or start a service.
|
||||
@@ -83,6 +86,12 @@ func Find_driver(id string) (Driver, error) {
|
||||
}
|
||||
|
||||
func Open_driver(id string, options Options) (Transport, error) {
|
||||
return Open_driver_context(context.Background(), id, options)
|
||||
}
|
||||
|
||||
// Open_driver_context bounds connection setup without binding the live client to ctx.
|
||||
func Open_driver_context(ctx context.Context, id string, options Options) (Transport, error) {
|
||||
options.context = ctx
|
||||
driver, err := Find_driver(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -93,7 +102,11 @@ func Open_driver(id string, options Options) (Transport, error) {
|
||||
if err = driver.Availability(); err != nil {
|
||||
return nil, fmt.Errorf("speech driver %s unavailable: %w", id, err)
|
||||
}
|
||||
return driver.Open(options)
|
||||
client, err := driver.Open(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// discover_modules uses a separate, bounded connection. It never changes the
|
||||
@@ -103,7 +116,7 @@ func discover_modules(options Options) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer wire.conn.Close()
|
||||
defer wire.close()
|
||||
modules, err := wire.command("LIST OUTPUT_MODULES")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user