def __init__(self, host, port, key, app, service, topic, lang, format, logger=None): self.host = host self.port = port self.key = key self.app = app self.topic = topic self.service = service self.lang = lang self.format = format self.uuid = randomUuid().hex self.logger = logger self.log("uuid={0}".format(self.uuid)) self.session_id = "" self.connect()
from basic_pb2 import ConnectionResponse from voiceproxy_pb2 import ConnectionRequest, AddData, AddDataResponse, AdvancedASROptions from transport import Transport, TransportError from concurrent.futures import ThreadPoolExecutor, Future DEFAULT_KEY_VALUE = 'paste-your-own-key' DEFAULT_SERVER_VALUE = 'asr.yandex.net' DEFAULT_PORT_VALUE = 80 DEFAULT_FORMAT_VALUE = 'audio/x-pcm;bit=16;rate=16000' # 'audio/x-pcm;bit=16;rate=8000' # use this format for 8k bitrate wav and pcm DEFAULT_MODEL_VALUE = 'freeform' DEFAULT_LANG_VALUE = 'ru-RU' DEFAULT_UUID_VALUE = randomUuid().hex DEFAULT_CHUNK_SIZE_VALUE = 1024 * 32 * 2 DEFAULT_RECONNECT_DELAY = 0.5 DEFAULT_RECONNECT_RETRY_COUNT = 5 DEFAULT_PENDING_LIMIT = 50 DEFAULT_INTER_UTT_SILENCE = 120 DEFAULT_CMN_LATENCY = 50 def bytes_in_sec(format): if "8000" in format: return 16000 else: return 32000
from voiceproxy_pb2 import ConnectionRequest, AddData, AddDataResponse, AdvancedASROptions from transport import Transport, TransportError from concurrent.futures import ThreadPoolExecutor, Future DEFAULT_KEY_VALUE = 'paste-your-own-key' DEFAULT_SERVER_VALUE = 'asr.yandex.net' DEFAULT_PORT_VALUE = 80 DEFAULT_FORMAT_VALUE = 'audio/x-pcm;bit=16;rate=16000' # 'audio/x-pcm;bit=16;rate=8000' # use this format for 8k bitrate wav and pcm DEFAULT_MODEL_VALUE = 'freeform' DEFAULT_LANG_VALUE = 'ru-RU' DEFAULT_UUID_VALUE = randomUuid().hex DEFAULT_CHUNK_SIZE_VALUE = 1024*32*2 DEFAULT_RECONNECT_DELAY = 0.5 DEFAULT_RECONNECT_RETRY_COUNT = 5 DEFAULT_PENDING_LIMIT = 50 DEFAULT_INTER_UTT_SILENCE = 120 DEFAULT_CMN_LATENCY = 50 def bytes_in_sec(format): if "8000" in format: return 16000 else: return 32000
def configure(self, package, argv): super().configure(package, argv) if self.args.uuid: self.uuid = UUID(self.args.uuid) else: self.uuid = randomUuid()