Skip to content

Commit

Permalink
chore:disable decode voice in ai,its too solw
Browse files Browse the repository at this point in the history
  • Loading branch information
ivhu committed Nov 20, 2024
1 parent f33fa76 commit 9681888
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions handler/gemini_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package handler
import (
"chatbot/ai"
"chatbot/ai/gemini"
"chatbot/cloudResources/tencent"
"chatbot/config"
"chatbot/utils"
"regexp"
"strings"
"sync"
Expand Down Expand Up @@ -142,19 +140,20 @@ func handlePrivateChat(b *gotgbot.Bot, ctx *ext.Context, ai ai.AiInterface) erro
}
}
}()
if ctx.EffectiveMessage.Voice != nil {
file, err := utils.DownloadFileByFileID(ctx.EditedBusinessMessage.Voice.FileId, b)
if err != nil {
log.Error().Err(err).Msg("failed to download file")
} else {
output, err := tencent.GetTencentClient().AudioToText(file)
if err != nil {
log.Error().Err(err).Msg("failed to get audio text")
} else {
input += "\n" + output
}
}
}
// 语音解析虽然好用,但是太慢了
// if ctx.EffectiveMessage.Voice != nil {
// file, err := utils.DownloadFileByFileID(ctx.EditedBusinessMessage.Voice.FileId, b)
// if err != nil {
// log.Error().Err(err).Msg("failed to download file")
// } else {
// output, err := tencent.GetTencentClient().AudioToText(file)
// if err != nil {
// log.Error().Err(err).Msg("failed to get audio text")
// } else {
// input += "\n" + output
// }
// }
// }

resp, err := ai.Chat(sender, input)
if err != nil {
Expand Down

0 comments on commit 9681888

Please sign in to comment.