feat: add realtime ASR voice chat with Cobra subcommand
This commit is contained in:
1 parent
dab8cbb55d
commit
74367f39e0
17 files changed
+977
-82
No files matched your search
@@ -0,0 +1,35 @@
|
||||
// Package cli 定义终端助手的文字与语音命令入口。
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"example.com/ueino/adk/internal/config"
|
||||
"example.com/ueino/adk/internal/terminal"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
return newCommand(terminal.Run)
|
||||
}
|
||||
|
||||
func newCommand(run func(context.Context, config.Config, bool) error) *cobra.Command {
|
||||
var cfg config.Config
|
||||
root := &cobra.Command{
|
||||
Use: "adk", Short: "Eino ADK 终端助手,默认使用文字聊天",
|
||||
Args: cobra.NoArgs, SilenceUsage: true, SilenceErrors: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return run(cmd.Context(), cfg.Resolve(), false)
|
||||
},
|
||||
}
|
||||
root.CompletionOptions.DisableDefaultCmd = true
|
||||
cfg.BindFlags(root.PersistentFlags())
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "voice", Short: "使用麦克风进行语音聊天",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return run(cmd.Context(), cfg.Resolve(), true)
|
||||
},
|
||||
})
|
||||
return root
|
||||
}
|
||||
Reference in new issue
Block a user