Skip to content

Commit

Permalink
Some import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovcmedeiros committed Nov 16, 2023
1 parent 1a5282b commit 7046c74
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyrobbot/voice_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import chime
import numpy as np
import pydub
import pygame
import scipy.io.wavfile as wav
import soundfile as sf
import speech_recognition as sr
Expand All @@ -19,9 +18,8 @@
from loguru import logger
from openai import OpenAI

from pyrobbot.chat_configs import VoiceChatConfigs

from .chat import Chat
from .chat_configs import VoiceChatConfigs
from .openai_utils import CannotConnectToApiError, retry_api_call

try:
Expand Down Expand Up @@ -60,9 +58,12 @@ def __init__(self, configs: VoiceChatConfigs = default_configs):
raise ImportError(
"Module `sounddevice`, needed for audio recording, is not available."
)
# Import it here to prevent the hello message from being printed when not needed
import pygame

super().__init__(configs=configs)

self.pygame = pygame
self.mixer = pygame.mixer
self.vad = webrtcvad.Vad(2)
self.mixer.init()
Expand Down Expand Up @@ -161,7 +162,7 @@ def speak(self, sound_obj_queue: queue.Queue):
sound = sound_obj_queue.get()
_channel = sound.play()
while self._assistant_still_talking():
pygame.time.wait(100)
self.pygame.time.wait(100)
sound_obj_queue.task_done()

def listen(self):
Expand Down

0 comments on commit 7046c74

Please sign in to comment.