remove pyq goodbye model and rime synthesizer and fix environment loading

This commit is contained in:
Ajay Raj 2023-03-28 10:20:36 -07:00
commit 1dc7bc74c3
28 changed files with 143 additions and 285 deletions

View file

@ -1,4 +1,3 @@
import os
from typing import Optional
import openai
from langchain.prompts import (
@ -10,6 +9,7 @@ from langchain.prompts import (
from langchain.chains import ConversationChain
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory
from vocode import getenv
from vocode.turn_based.agent.base_agent import BaseAgent
@ -25,7 +25,7 @@ class ChatGPTAgent(BaseAgent):
max_tokens: int = 100,
):
super().__init__(initial_message=initial_message)
openai.api_key = os.getenv("OPENAI_API_KET", api_key)
openai.api_key = getenv("OPENAI_API_KET", api_key)
if not openai.api_key:
raise ValueError("OpenAI API key not provided")
self.prompt = ChatPromptTemplate.from_messages(

View file

@ -1,7 +1,7 @@
import os
from typing import Optional
import azure.cognitiveservices.speech as speechsdk
from pydub import AudioSegment
from vocode import getenv
from vocode.turn_based.synthesizer.base_synthesizer import BaseSynthesizer
@ -15,8 +15,8 @@ class AzureSynthesizer(BaseSynthesizer):
):
self.sampling_rate = sampling_rate
speech_config = speechsdk.SpeechConfig(
subscription=os.getenv("AZURE_SPEECH_KEY", api_key),
region=os.getenv("AZURE_SPEECH_REGION", region),
subscription=getenv("AZURE_SPEECH_KEY", api_key),
region=getenv("AZURE_SPEECH_REGION", region),
)
if self.sampling_rate == 44100:
speech_config.set_speech_synthesis_output_format(

View file

@ -1,8 +1,8 @@
import io
import os
from typing import Optional
from pydub import AudioSegment
import requests
from vocode import getenv
from vocode.turn_based.synthesizer.base_synthesizer import BaseSynthesizer
ELEVEN_LABS_BASE_URL = "https://api.elevenlabs.io/v1/"
@ -11,7 +11,7 @@ ELEVEN_LABS_BASE_URL = "https://api.elevenlabs.io/v1/"
class ElevenLabsSynthesizer(BaseSynthesizer):
def __init__(self, voice_id: str, api_key: Optional[str] = None):
self.voice_id = voice_id
self.api_key = os.getenv("ELEVEN_LABS_API_KEY", api_key)
self.api_key = getenv("ELEVEN_LABS_API_KEY", api_key)
def synthesize(self, text: str) -> AudioSegment:
url = ELEVEN_LABS_BASE_URL + f"text-to-speech/{self.voice_id}"

View file

@ -1,15 +1,15 @@
from typing import Optional
from pydub import AudioSegment
import io
import os
import openai
from vocode import getenv
from vocode.turn_based.transcriber.base_transcriber import BaseTranscriber
class WhisperTranscriber(BaseTranscriber):
def __init__(self, api_key: Optional[str] = None):
openai.api_key = os.getenv("OPENAI_API_KEY", api_key)
openai.api_key = getenv("OPENAI_API_KEY", api_key)
if not openai.api_key:
raise ValueError("OpenAI API key not provided")