Skip to content

Commit 48c7a9f

Browse files
committed
handle no pyaudio
1 parent 9d027da commit 48c7a9f

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

agixtsdk/__init__.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
get_type_hints,
1212
)
1313
from pydantic import BaseModel
14-
from pydub import AudioSegment
1514
from datetime import datetime
1615
from enum import Enum
1716
import tiktoken
@@ -24,7 +23,11 @@
2423
import time
2524
import json
2625
import os
26+
try:
2727

28+
from pydub import AudioSegment
29+
except:
30+
pass
2831

2932
class ChatCompletions(BaseModel):
3033
model: str = "gpt4free" # This is the agent name
@@ -1517,9 +1520,12 @@ async def chat_completions(
15171520
with open(audio_url, "wb") as f:
15181521
f.write(audio_data)
15191522
wav_file = f"./WORKSPACE/{uuid.uuid4().hex}.wav"
1520-
AudioSegment.from_file(audio_url).set_frame_rate(16000).export(
1523+
try:
1524+
AudioSegment.from_file(audio_url).set_frame_rate(16000).export(
15211525
wav_file, format="wav"
15221526
)
1527+
except:
1528+
pass
15231529
# Switch this to use the endpoint
15241530
openai.api_key = (
15251531
self.headers["Authorization"]
@@ -1532,10 +1538,13 @@ async def chat_completions(
15321538
message=f"[ACTIVITY] Transcribing audio to text.",
15331539
conversation_name=conversation_name,
15341540
)
1535-
with open(wav_file, "rb") as audio_file:
1536-
transcription = openai.audio.transcriptions.create(
1537-
model=agent_name, file=audio_file
1541+
try:
1542+
with open(wav_file, "rb") as audio_file:
1543+
transcription = openai.audio.transcriptions.create(
1544+
model=agent_name, file=audio_file
15381545
)
1546+
except:
1547+
pass
15391548
new_prompt += transcription.text
15401549
if "video_url" in msg:
15411550
video_url = str(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name="agixtsdk",
11-
version="0.0.77",
11+
version="0.0.78",
1212
description="The AGiXT SDK for Python.",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)