Module: ChatgptAssistant::Bots::Discord::VoiceActions
- Included in:
- DiscordBot
- Defined in:
- lib/chatgpt_assistant/bots/discord/voice_actions.rb
Instance Method Summary collapse
- #ask_to_speak_action ⇒ Object
- #disconnect_action ⇒ Object
- #discord_voice_bot_connect ⇒ Object
- #speak_answer_action(audio_path, response) ⇒ Object
Instance Method Details
#ask_to_speak_action ⇒ Object
7 8 9 10 11 12 |
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 7 def ask_to_speak_action Message.create(chat_id: chat.id, content: , role: "user", discord_message_id: evnt..id) response = chatter.chat(, chat.id, [:something_went_wrong]) audio_path = synthesis.synthesize_text(response) speak_answer_action(audio_path, response) end |
#disconnect_action ⇒ Object
26 27 28 29 |
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 26 def disconnect_action bot.voice_destroy(evnt.user.voice_channel) "Disconnected from voice channel" end |
#discord_voice_bot_connect ⇒ Object
21 22 23 24 |
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 21 def discord_voice_bot_connect bot.voice_connect(evnt.user.voice_channel) if discord_voice_bot_disconnected? discord_voice_bot_connected? ? "Connected to voice channel" : "Error connecting to voice channel" end |
#speak_answer_action(audio_path, response) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 14 def speak_answer_action(audio_path, response) response evnt.voice.play_file(audio_path) delete_file audio_path "OK" end |