google env fixes
This commit is contained in:
parent
ecebe4c1a5
commit
11af47482c
4 changed files with 13 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vocode"
|
name = "vocode"
|
||||||
version = "0.1.61"
|
version = "0.1.63"
|
||||||
description = "The all-in-one voice SDK"
|
description = "The all-in-one voice SDK"
|
||||||
authors = ["Ajay Raj <ajay@vocode.dev>"]
|
authors = ["Ajay Raj <ajay@vocode.dev>"]
|
||||||
license = "MIT License"
|
license = "MIT License"
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,14 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio import Future
|
|
||||||
from ctypes import Union
|
|
||||||
import queue
|
import queue
|
||||||
from typing import Callable, Awaitable, Optional, Any
|
from typing import Optional, Any
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import secrets
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from vocode.streaming.agent.bot_sentiment_analyser import (
|
from vocode.streaming.agent.bot_sentiment_analyser import (
|
||||||
BotSentiment,
|
|
||||||
BotSentimentAnalyser,
|
BotSentimentAnalyser,
|
||||||
)
|
)
|
||||||
from vocode.streaming.agent.information_retrieval_agent import InformationRetrievalAgent
|
|
||||||
from vocode.streaming.factory import (
|
from vocode.streaming.factory import (
|
||||||
create_agent,
|
create_agent,
|
||||||
create_synthesizer,
|
create_synthesizer,
|
||||||
|
|
@ -21,26 +16,16 @@ from vocode.streaming.factory import (
|
||||||
)
|
)
|
||||||
from vocode.streaming.models.message import BaseMessage
|
from vocode.streaming.models.message import BaseMessage
|
||||||
from vocode.streaming.output_device.base_output_device import BaseOutputDevice
|
from vocode.streaming.output_device.base_output_device import BaseOutputDevice
|
||||||
from vocode.streaming.transcriber.assembly_ai_transcriber import AssemblyAITranscriber
|
|
||||||
from vocode.streaming.utils.goodbye_model import GoodbyeModel
|
from vocode.streaming.utils.goodbye_model import GoodbyeModel
|
||||||
from vocode.streaming.utils.transcript import Transcript
|
from vocode.streaming.utils.transcript import Transcript
|
||||||
|
|
||||||
from vocode.streaming.models.transcriber import (
|
|
||||||
TranscriberConfig,
|
|
||||||
TranscriberType,
|
|
||||||
)
|
|
||||||
from vocode.streaming.models.agent import (
|
from vocode.streaming.models.agent import (
|
||||||
AgentConfig,
|
|
||||||
AgentType,
|
|
||||||
FillerAudioConfig,
|
FillerAudioConfig,
|
||||||
FILLER_AUDIO_DEFAULT_SILENCE_THRESHOLD_SECONDS,
|
FILLER_AUDIO_DEFAULT_SILENCE_THRESHOLD_SECONDS,
|
||||||
)
|
)
|
||||||
from vocode.streaming.models.synthesizer import (
|
from vocode.streaming.models.synthesizer import (
|
||||||
SynthesizerConfig,
|
|
||||||
SynthesizerType,
|
|
||||||
TrackBotSentimentConfig,
|
TrackBotSentimentConfig,
|
||||||
)
|
)
|
||||||
from vocode.streaming.models.websocket import AudioMessage
|
|
||||||
from vocode.streaming.constants import (
|
from vocode.streaming.constants import (
|
||||||
TEXT_TO_SPEECH_CHUNK_SIZE_SECONDS,
|
TEXT_TO_SPEECH_CHUNK_SIZE_SECONDS,
|
||||||
PER_CHUNK_ALLOWANCE_SECONDS,
|
PER_CHUNK_ALLOWANCE_SECONDS,
|
||||||
|
|
@ -104,6 +89,7 @@ class StreamingConversation:
|
||||||
self.bot_sentiment_analyser = BotSentimentAnalyser(
|
self.bot_sentiment_analyser = BotSentimentAnalyser(
|
||||||
emotions=self.track_bot_sentiment_config.emotions
|
emotions=self.track_bot_sentiment_config.emotions
|
||||||
)
|
)
|
||||||
|
if self.agent.get_agent_config().end_conversation_on_goodbye:
|
||||||
self.goodbye_model = GoodbyeModel()
|
self.goodbye_model = GoodbyeModel()
|
||||||
|
|
||||||
self.is_human_speaking = False
|
self.is_human_speaking = False
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import io
|
import io
|
||||||
|
import os
|
||||||
import wave
|
import wave
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
|
@ -23,10 +24,12 @@ class GoogleSynthesizer(BaseSynthesizer):
|
||||||
def __init__(self, synthesizer_config: GoogleSynthesizerConfig):
|
def __init__(self, synthesizer_config: GoogleSynthesizerConfig):
|
||||||
super().__init__(synthesizer_config)
|
super().__init__(synthesizer_config)
|
||||||
# Instantiates a client
|
# Instantiates a client
|
||||||
if not getenv("GOOGLE_APPLICATION_CREDENTIALS"):
|
credentials_path = getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
||||||
|
if not credentials_path:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"GOOGLE_APPLICATION_CREDENTIALS environment variable must be set"
|
"Please set GOOGLE_APPLICATION_CREDENTIALS environment variable"
|
||||||
)
|
)
|
||||||
|
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
|
||||||
self.client = tts.TextToSpeechClient()
|
self.client = tts.TextToSpeechClient()
|
||||||
|
|
||||||
# Build the voice request, select the language code ("en-US") and the ssml
|
# Build the voice request, select the language code ("en-US") and the ssml
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import queue
|
import queue
|
||||||
from google.cloud import speech
|
from google.cloud import speech
|
||||||
|
|
@ -19,10 +20,12 @@ class GoogleTranscriber(BaseTranscriber):
|
||||||
super().__init__(transcriber_config)
|
super().__init__(transcriber_config)
|
||||||
self._queue = queue.Queue()
|
self._queue = queue.Queue()
|
||||||
self._ended = False
|
self._ended = False
|
||||||
if not getenv("GOOGLE_APPLICATION_CREDENTIALS"):
|
credentials_path = getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
||||||
|
if not credentials_path:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Please set GOOGLE_APPLICATION_CREDENTIALS environment variable"
|
"Please set GOOGLE_APPLICATION_CREDENTIALS environment variable"
|
||||||
)
|
)
|
||||||
|
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
|
||||||
self.google_streaming_config = self.create_google_streaming_config()
|
self.google_streaming_config = self.create_google_streaming_config()
|
||||||
self.client = speech.SpeechClient()
|
self.client = speech.SpeechClient()
|
||||||
self.warmed_up = False
|
self.warmed_up = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue