Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description="Streaming example.")
    parser.add_argument("--config", type=str)
    parser.add_argument("--secure", default=False, action="store_true")
    args = parser.parse_args()

    with open(args.config) as f:
        config: ClientConfig = ClientConfig.from_json(f.read())

    client: Client = Client(config=config, use_secure_channel=args.secure)
    sessions_service: Sessions = client.services.sessions

    # Get audio stream (iterator of audio chunks)
    audio_stream: Iterator[bytes] = get_streaming_audio(AUDIO_FILE)

    # Create streaming request
    streaming_request: Iterator[StreamingDetectIntentRequest] = create_streaming_request(audio_stream)

    # get back responses
    for i, response in enumerate(sessions_service.streaming_detect_intent(streaming_request)):
        print(response.query_result.fulfillment_messages)
        with open(f"response_{i + 1}.wav", "wb") as f:
            f.write(response.audio)
Exemple #2
0
import ondewo.nlu.agent_pb2 as agent
import ondewo.s2t.speech_to_text_pb2 as s2t
import ondewo.t2s.text_to_speech_pb2 as t2s
from ondewo.nlu.client import Client as NluClient
from ondewo.nlu.client_config import ClientConfig as NluClientConfig
from ondewo.s2t.client.client import Client as S2tClient
from ondewo.t2s.client.client import Client as T2sClient

from ondewo.csi.client.client import Client as CsiClient
from ondewo.csi.client.client_config import ClientConfig

with open("csi.json") as fi:
    config = ClientConfig.from_json(fi.read())
with open("csi.json") as fi:
    nlu_config = NluClientConfig.from_json(fi.read())

csi_client = CsiClient(config=config)
s2t_client = S2tClient(config=config)
t2s_client = T2sClient(config=config)
nlu_client = NluClient(config=nlu_config)

s2t_pipelines = s2t_client.services.speech_to_text.list_s2t_pipelines(request=s2t.ListS2tPipelinesRequest())
t2s_pipelines = t2s_client.services.text_to_speech.list_t2s_pipelines(request=t2s.ListT2sPipelinesRequest())

print(f"Speech to text pipelines: {[pipeline.id for pipeline in s2t_pipelines.pipeline_configs]}")
print(f"Text to speech pipelines: {[pipeline.id for pipeline in t2s_pipelines.pipelines]}")

agents = nlu_client.services.agents.list_agents(request=agent.ListAgentsRequest())

print(f"Nlu agents: {[agent.agent.parent for agent in agents.agents_with_owners]}")