[Yandex Cloud documentation](../index.md) > [Yandex SpeechKit Hybrid](index.md) > Creating a demo stand > Creating a SpeechKit Hybrid stand

# Creating a SpeechKit Hybrid demo stand

SpeechKit Hybrid enables Yandex SpeechKit speech [recognition](stt/testing.md) and [synthesis](tts/testing.md). You can deploy your SpeechKit Hybrid demo stand using Yandex Cloud services through Terraform. This way, you can test recognition and synthesis applications hosted in Docker containers.

Creating a demo stand involves using two machines:

* Local one (in our example, it is Linux-based).
* Virtual one that meets the SpeechKit Hybrid [system requirements](system-requirements.md). This VM runs Docker containers.

Our demo stand uses the [Cloud Billing](pricing.md#billing) licensing model; this means the info on each request to SpeechKit Hybrid is [sent](architecture.md) to Yandex Cloud Billing.

To deploy your SpeechKit Hybrid demo stand:

1. [Get started with Yandex Cloud](#get-started).
1. [Install additional dependencies](#prepare).
1. [Prepare the SSH keys](#ssh).
1. [Add variables for the Terraform configuration](#variables).
1. [Create the infrastructure using Terraform](#create-infrastructure).
1. [Set up a permanent communication channel with the Yandex Cloud server](#communication-channel).
1. [Perform load testing for speech recognition and synthesis](#stt-and-tts).

In case of errors, use our [debugging guide](quickstart-debugging.md).

## Get started with Yandex Cloud {#get-started}

1. Sign up for Yandex Cloud. Signing up is different for individuals and legal entities:

   * [How to sign up as an individual](../getting-started/individuals/registration.md)
   * [How to sign up as a business](../getting-started/legal-entity/registration.md)

1. Go to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud.
1. Create a folder in the management console. It will contain your resources:

   1. In the [management console](https://console.yandex.cloud), in the top panel, click ![image](../_assets/console-icons/layout-side-content-left.svg) or ![image](../_assets/console-icons/chevron-down.svg) and select the [cloud](../resource-manager/concepts/resources-hierarchy.md#cloud).
   1. To the right of the cloud name, click ![image](../_assets/console-icons/ellipsis.svg).
   1. Select ![image](../_assets/console-icons/plus.svg) **Create folder**.
   
      ![create-folder1](../_assets/resource-manager/create-folder-1.png)
   
   1. Give your [folder](../resource-manager/concepts/resources-hierarchy.md#folder) a name. The naming requirements are as follows:
   
       * Length: between 3 and 63 characters.
       * It can only contain lowercase Latin letters, numbers, and hyphens.
       * It must start with a letter and cannot end with a hyphen.
   
   1. Optionally, specify the description for your folder.
   1. Select **Create a default network**. This will create a [network](../vpc/concepts/network.md#network) with subnets in each availability zone. Within this network, you will also have a [default security group](../vpc/concepts/security-groups.md#default-security-group), within which all network traffic will be allowed.
   1. Click **Create**.
   
      ![create-folder2](../_assets/resource-manager/create-folder-2.png)

1. [Create a service account](../iam/operations/sa/create.md) named `sk-hybrid-example`.

   With a service account, you can flexibly configure access permissions. For more information, see [Service accounts](../iam/concepts/users/service-accounts.md).

1. [Assign the following roles to the service account](../iam/operations/sa/assign-role-for-sa.md):

   * `compute.editor`: To create a Yandex Cloud VM.
   * `container-registry.images.puller`: To work with Docker images in the [Yandex Container Registry](../container-registry/index.md) registry.
   * `iam.serviceAccounts.keyAdmin`: To create an [API key](../iam/concepts/authorization/api-key.md) for authentication in Yandex Cloud Billing.

1. [Create an API key](../iam/operations/authentication/manage-api-keys.md#create-api-key).

   Save the ID and the secret part of the key. You cannot request them later.

1. [Create a registry](../container-registry/operations/registry/registry-create.md) in Container Registry.
1. [Send the registry ID to the SpeechKit](https://center.yandex.cloud/support) team. The required containers and images will appear in your registry.

## Install additional dependencies {#prepare}

On a local machine:

1. [Install the Yandex Cloud command line interface](../cli/operations/install-cli.md) (CLI).
1. [Authenticate your service account](../cli/operations/authentication/service-account.md) via the CLI.
1. [Install Terraform](../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).

## Prepare a repository with the Terraform configuration {#repository}

On a local machine:

1. Clone the [repository with the Terraform configuration](https://github.com/yandex-cloud-examples/yc-speechkit-hybrid-deployment/) from which the required infrastructure will be deployed:

   ```bash
   git clone git@github.com:yandex-cloud-examples/yc-speechkit-hybrid-deployment.git
   ```

1. In the terminal, go to the cloned repository directory.

## Prepare the SSH keys {#ssh}

You will need the SSH keys for authentication when connecting to the Yandex Cloud VM. To prepare them, perform the following steps on the local machine:

1. If you do not have a pair containing a public and private SSH key, create one:

   ```bash
   ssh-keygen -t rsa -f $HOME/.ssh/speechkit_hybrid
   ```

   After running this command, you will be prompted to enter the password for the private key. If you do not want to provide a password, click **Enter**.

1. In the directory of the cloned repository, create a symbolic link that points to the public SSH key:

   ```bash
   ln -s ~/.ssh/<key_name>.pub ./keys/ssh-user-id-rsa.pub
   ```

   This command provides the following:

   * `~/.ssh/<key_name>.pub`: File with a public SSH key. If you created the key in the previous step, specify `~/.ssh/speechkit_hybrid.pub`.
   * `./keys/ssh-user-id-rsa.pub`: Symbolic link. The path is relative to the current repository directory.

## Add variables for the Terraform configuration {#variables}

The `yc-speechkit-hybrid-deployment` repository directory contains the `terraform.tfvars.template` file. It is a Terraform template by which environment variables are set. These variables are provided to the CLI and Terraform when executing commands.

To set variables for the Terraform configuration, perform the following steps on the local machine:

1. Create a copy of the Terraform template in the `yc-speechkit-hybrid-deployment` repository directory:

   ```bash
   cp ./terraform.tfvars.template ./terraform.tfvars
   ```

1. In the `terraform.tfvars` file, specify the values of the following variables:

   * `CR_REGISTRY_ID`: Container Registry registry ID.
   * `BILLING_STATIC_API_KEY`: Secret part of the API key.

1. (Optional) Add the `NODES_GPU_INTERRUPTIBLE = false` variable.

   The Terraform configuration in the repository assumes creating an [interruptible VM](../compute/concepts/preemptible-vm.md). You can disable interrupting using the `NODES_GPU_INTERRUPTIBLE` variable. Its default value is `true`, and it is specified in the `variables.tf` file in the `yc-speechkit-hybrid-deployment` repository.

## Create an infrastructure using Terraform {#create-infrastructure}

The infrastructure required to work with SpeechKit Hybrid is described in the `networks.tf` and `node-deploy.tf` files in the `yc-speechkit-hybrid-deployment` repository. The `networks.tf` file contains the configuration of the following entities:

* Network
* Subnet
* Internal DNS zone
* Security group

The `node-deploy.tf` file contains the VM and SpeechKit Hybrid configuration.

Read more about entity configuration on the [Terraform](../terraform/index.md) website and in the relevant Yandex Cloud service documentation.

To create the infrastructure, perform the following steps on the local machine:

{% list tabs group=instructions %}

- Terraform {#tf}

   1. In the terminal, go to the `yc-speechkit-hybrid-deployment` repository directory.
   1. [Get](../tutorials/infrastructure-management/terraform-quickstart.md#get-credentials) the `sk-hybrid-example` service account authentication credentials You can add the data to environment variables or specify this data in the `main.tf` file under `provider "yandex"`.
   1. [Configure and initialize the Terraform providers](../tutorials/infrastructure-management/terraform-quickstart.md#configure-provider).

      The repository uses the `main.tf` file as a configuration file with provider settings, so there is no need to recreate such a file.

   1. Validate your Terraform configuration files using this command:

      ```bash
      terraform validate
      ```

   1. Create an infrastructure:

      1. Run this command to view the planned changes:
      
         ```bash
         terraform plan
         ```
      
         If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
      
      1. If everything looks correct, apply the changes:
         1. Run this command:
      
            ```bash
            terraform apply
            ```
      
         1. Confirm updating the resources.
         1. Wait for the operation to complete.

      All the required resources will be created in the specified folder. You can check resource availability and their settings in the [management console](https://console.yandex.cloud).

{% endlist %}

## Set up a permanent communication channel with the Yandex Cloud server {#communication-channel}

To work according to the Cloud Billing licensing model, ensure network connectivity between the Yandex Cloud Billing `billing.datasphere.yandexcloud.net:443` node and the VM on which SpeechKit Hybrid is deployed. To check the node for availability:

1. On the local machine, get the public IP address of the created VM:

   ```bash
   yc compute instance list
   ```

   The public address will be needed to connect to the VM.

   Result example:

   ```text
   +-----------+-------------------------------+---------------+---------+-------------+--------------+
   |     ID    |              NAME             |    ZONE ID    | STATUS  | EXTERNAL IP | INTERNAL IP  |
   +-----------+-------------------------------+---------------+---------+-------------+--------------+
   | fhmjvr*** | sk-hybrid-compose-example-*** | ru-central1-a | RUNNING | 158.160.*** | 192.168.***  |
   | ...                                                                                              |
   +-----------+-------------------------------+---------------+---------+-------------+--------------+
   ```

   The public address is specified in the `EXTERNAL IP` field.

1. [Connect to the VM over SSH](../compute/operations/vm-connect/ssh.md#vm-connect):

   ```bash
   ssh <username>@<VM_public_IP_address>
   ```

   Where `<username>` is the VM account username.

1. Run this command:

   ```bash
   nc -vz billing.datasphere.yandexcloud.net 443
   ```

   If the node is available over the network, the command will return the following result:

   ```text
   Connection to billing.datasphere.yandexcloud.net 443 port [tcp/https] succeeded!
   ```

## Perform load testing for speech recognition and synthesis {#stt-and-tts}

To check whether the SpeechKit Hybrid test installation is valid and its performance is fine, use Docker containers with the load testing utility for speech recognition and synthesis. These containers are described in the `node-deploy.tf` file, they were created along with the [infrastructure](#create-infrastructure).

To run a load test:

1. Connect to the VM over SSH.
1. Make sure ports `8080` and `9080` are open to receive client requests:

   ```bash
   telnet <VM_public_address> 8080 && telnet <VM_public_address> 9080
   ```

1. Run speech recognition:

   ```bash
   docker run --rm --name stt-tools \
      --env ENVOY_HOST=<VM_public_address> \
      --env ENVOY_PORT=8080 \
      --env CONNECTIONS=40 \
      cr.yandex/<registry_ID>/release/tools/stt-tools:0.20
   ```

   In the command, specify the public IP address of the VM and the ID of the previously created Container Registry registry.

   Where:

   * `ENVOY_HOST`: IP address of the recognition service.
   * `ENVOY_PORT`: Port of the recognition service (`8080` by default).
   * `CONNECTIONS`: Number of simultaneously active channels.

1. Run speech synthesis:

   ```bash
   docker run --rm --name tts-tools \
      --network=host \
      --env ENVOY_HOST=<VM_public_address> \
      --env ENVOY_TTS_PORT=9080 \
      --env RPS=20 \
      cr.yandex/<registry_ID>/release/tools/tts-tools:0.20
   ```

   In the command, specify the public IP address of the VM and the ID of the previously created Container Registry registry.

   Where:

   * `ENVOY_HOST`: IP address of the speech synthesis service.
   * `ENVOY_TTS_PORT`: Port of the synthesis service (`9080` by default).
   * `RPS`: Number of speech synthesis requests per second.

1. Wait a few minutes while speech recognition and synthesis are performed.
1. Look at the test results in the container logs:

   * `docker logs stt-tools` for speech recognition.
   * `docker logs tts-tools` for speech synthesis.

   Until the `Load finished. Ready to serve requests on 0.0.0.0:17001` line appears in the logs, the speech recognition and synthesis services will not be responding to requests. You may need to wait from 2 to 10 minutes.

   Next, the logs will show a message that the [Envoy](architecture.md) component has started listening to port `8080` for speech recognition and port `9080` for speech synthesis. This means SpeechKit Hybrid is running and ready to serve client requests.

1. Optionally, stop load testing.

   During load testing, the `docker run` commands will not respond to the **Ctrl** + **C** interrupt signals. If you want to stop the containers from running, run the following command:

   * `docker stop stt-tools` for speech recognition.
   * `docker stop tts-tools` for speech synthesis.