gRPC setup

Before developing and running client applications, you need to set up the gRPC environment for your programming language on Linux or Windows.

Basic steps

The basic steps in using the ASRaaS gRPC protocol are:

  1. Install gRPC for the programming language of your choice, including C++, Java, Python, Go, Ruby, C#, Node.js, and others. See gRPC Documentation  for a complete list and instructions on using gRPC with each one. For example, for Python:

    python3 -m pip install --upgrade pip
    python3 -m pip install grpcio
    python3 -m pip install grpcio-tools
    python -m pip install --upgrade pip
    python -m pip install grpcio
    python -m pip install grpcio-tools
  2. Download one or more of the ASRaaS gRPC proto files, which contain a generic version of the functions or classes for creating ASRaaS applications. Three sets of files are available:

    • Recognizer protos: nuance-asr-rpc-protos.zip. These files are for requesting recognition.

    • (Optional) Training protos: nuance-training-rpc-protos.zip. These files are for compiling wordsets.

    • (Optional) ForgetMe protos: nuance-forgetme-protos.zip. These files are for deleting speaker profiles.

  3. Unzip the files into the directory that contains or will contain your client apps, for example /home/asr/clients on Linux or c:\ASR\clients on Windows. On Linux, use the unzip command:

    unzip nuance-asr-rpc-protos.zip
    unzip nuance-training-rpc-protos.zip  // Optional
    unzip nuance-forgetme-protos.zip      // Optional 
    

    The zip files contain common messaging files, error_details.proto, status_code.proto, and status.proto. If you already have these files, you may skip them. On Linux, answer [N]one when prompted:

    replace  nuance/rpc/error_details.proto? [y]es, [n]o, [A]ll, [N]one, [r]ename: N
    

    The zip files all extract to a directory structure starting with nuance:

    ├── Your client apps here
    └── nuance                        
        ├── asr                       
        |   ├── forgetme    // Optional 
        |   |   └── v1   
        |   |       └── forgetme.proto  
        │   ├── v1                    
        │   │   ├── recognizer.proto  
        │   │   ├── resource.proto    
        │   │   └── result.proto      
        │   └── v1beta1     // Optional
        │       └── training.proto
        └── rpc                       
            ├── error_details.proto   
            ├── status_code.proto     
            └── status.proto
    
  4. If your programming language requires client stub files, generate the stubs from the proto files using gRPC protoc, following the Python example as guidance.

    These stubs contain the methods and fields from the proto files as implemented in your programming language. Some languages, such as Node.js, can use the proto files directly, meaning client stubs are not required. Consult the gRPC documentation for your programming language.

    # Generate Python stubs for recognition
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/v1/recognizer.proto
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/asr/v1/resource.proto
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/asr/v1/result.proto
    
    # Generate Python stubs for RPC messages, if not already present
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/status.proto
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/status_code.proto
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/error_details.proto
    
    # Optionally generate Python stubs for wordset training
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/v1beta1/training.proto
    
    # Optionally generate Python stubs for ForgetMe
    python3 -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/forgetme/v1/forgetme.proto
    rem Generate Python stubs for recognition
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/v1/recognizer.proto
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/asr/v1/resource.proto
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/asr/v1/result.proto
    
    rem Generate Python stubs for RPC messages, if not already present
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/status.proto
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/status_code.proto
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ nuance/rpc/error_details.proto
    
    rem Optionally generate Python stubs for wordset training
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/v1beta1/training.proto
    
    rem Optionally generate Python stubs for ForgetMe
    python -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ nuance/asr/forgetme/v1/forgetme.proto

    If you already have client stubs for the RPC files in this location, you may use the existing files.

Final structure

The resulting files contain the information in the proto files in your programming language:

├── Your client apps here
└── nuance                        
    ├── asr                       
    │   ├── forgetme  // Optional 
    │   │   └── v1
    │   │       ├── forgetme_pb2_grpc.py
    │   │       ├── forgetme_pb2.py
    │   │       └── forgetme.proto
    │   ├── v1                    
    │   │   ├── recognizer_pb2_grpc.py
    │   │   ├── recognizer_pb2.py
    │   │   ├── recognizer.proto
    │   │   ├── resource_pb2.py
    │   │   ├── resource.proto
    │   │   ├── result_pb2.py
    │   │   └── result.proto
    │   └── v1beta1
    │       ├── training_pb2_grpc.py
    │       ├── training_pb2.py
    │       └── training.proto
    └── rpc
        ├── error_details_pb2.py
        ├── error_details.proto
        ├── status_code_pb2.py
        ├── status_code.proto
        ├── status_pb2.py
        └── status.proto

What’s next?

Once you have the proto files and optionally the client stubs, you are ready to develop and run client applications with the help of sample clients: