Skip to content

Commit 1bee2dc

Browse files
committed
updating a few other spots, pytest shell helpers all pass.
1 parent 1e20a69 commit 1bee2dc

File tree

4 files changed

+62
-61
lines changed

4 files changed

+62
-61
lines changed

npcsh/audio.py

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,69 @@
66
import queue
77
import re
88
import json
9-
import torch
10-
import pyaudio
11-
import wave
12-
from typing import Optional, List, Dict, Any
13-
from gtts import gTTS
14-
from faster_whisper import WhisperModel
15-
import pygame
16-
17-
# Audio Configuration
18-
FORMAT = pyaudio.paInt16
19-
CHANNELS = 1
20-
RATE = 16000
21-
CHUNK = 512
22-
23-
# State Management
24-
is_speaking = False
25-
should_stop_speaking = False
26-
tts_sequence = 0
27-
recording_data = []
28-
buffer_data = []
29-
is_recording = False
30-
last_speech_time = 0
31-
running = True
32-
33-
# Queues
34-
audio_queue = queue.Queue()
35-
tts_queue = queue.PriorityQueue()
36-
cleanup_files = []
37-
38-
# Initialize pygame mixer
39-
pygame.mixer.quit()
40-
pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=512)
41-
42-
# Device selection
43-
device = "cpu"
44-
print(f"Using device: {device}")
459

46-
# Load VAD model
47-
print("Loading Silero VAD model...")
48-
vad_model, _ = torch.hub.load(
49-
repo_or_dir="snakers4/silero-vad",
50-
model="silero_vad",
51-
force_reload=False,
52-
onnx=False,
53-
verbose=False,
54-
)
55-
vad_model.to(device)
10+
import subprocess
5611

57-
# Load Whisper model
58-
print("Loading Whisper model...")
59-
whisper_model = WhisperModel("base", device=device, compute_type="int8")
12+
try:
13+
import torch
14+
import pyaudio
15+
import wave
16+
from typing import Optional, List, Dict, Any
17+
from gtts import gTTS
18+
from faster_whisper import WhisperModel
19+
import pygame
20+
21+
FORMAT = pyaudio.paInt16
22+
CHANNELS = 1
23+
RATE = 16000
24+
CHUNK = 512
25+
26+
# State Management
27+
is_speaking = False
28+
should_stop_speaking = False
29+
tts_sequence = 0
30+
recording_data = []
31+
buffer_data = []
32+
is_recording = False
33+
last_speech_time = 0
34+
running = True
35+
36+
# Queues
37+
audio_queue = queue.Queue()
38+
tts_queue = queue.PriorityQueue()
39+
cleanup_files = []
40+
41+
# Initialize pygame mixer
42+
pygame.mixer.quit()
43+
pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=512)
44+
45+
# Device selection
46+
device = "cpu"
47+
print(f"Using device: {device}")
48+
49+
# Load VAD model
50+
print("Loading Silero VAD model...")
51+
vad_model, _ = torch.hub.load(
52+
repo_or_dir="snakers4/silero-vad",
53+
model="silero_vad",
54+
force_reload=False,
55+
onnx=False,
56+
verbose=False,
57+
)
58+
vad_model.to(device)
6059

61-
# Conversation History Management
62-
history = []
63-
max_history = 10
64-
memory_file = "conversation_history.json"
60+
# Load Whisper model
61+
print("Loading Whisper model...")
62+
whisper_model = WhisperModel("base", device=device, compute_type="int8")
6563

66-
# Import the get_llm_response function
67-
from npcsh.llm_funcs import get_llm_response
68-
from npcsh.npc_sysenv import NPCSH_CHAT_PROVIDER, NPCSH_CHAT_MODEL, NPCSH_API_URL
69-
import subprocess
64+
# Conversation History Management
65+
history = []
66+
max_history = 10
67+
memory_file = "conversation_history.json"
7068

71-
print(NPCSH_CHAT_PROVIDER, NPCSH_CHAT_MODEL, NPCSH_API_URL)
7269

73-
import subprocess
70+
except:
71+
print("audio dependencies not installed")
7472

7573

7674
def convert_mp3_to_wav(mp3_file, wav_file):

npcsh/audio_gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# audio_gen.py

npcsh/conversation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
def get_litellm_conversation(
1515
messages: List[Dict[str, str]],
1616
model: str,
17+
provider: str,
1718
npc: Any = None,
1819
tools: list = None,
1920
api_key: str = None,

npcsh/dataframes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from typing import Optional
1010

1111
from npcsh.llm_funcs import get_llm_response
12-
from npcsh.audio import process_audio
13-
from npcsh.video import process_video
12+
13+
# from npcsh.audio import process_audio
14+
# from npcsh.video import process_video
1415

1516
from npcsh.load_data import (
1617
load_pdf,

0 commit comments

Comments
 (0)