运行推理

验证服务器健康状况

对 gRPC 端点执行健康检查。

  1. 此处安装 grpcurl

    在 Ubuntu 上运行的示例命令

    wget https://github.com/fullstorydev/grpcurl/releases/download/v1.9.1/grpcurl_1.9.1_linux_amd64.deb
    sudo dpkg -i grpcurl_1.9.1_linux_amd64.deb
    
  2. 下载健康检查 proto 文件

    wget https://raw.githubusercontent.com/grpc/grpc/master/src/proto/grpc/health/v1/health.proto
    
  3. <server_ip> 或 localhost 上运行健康检查

    grpcurl --plaintext --proto health.proto <server_ip>:8001 grpc.health.v1.Health/Check
    

如果服务已准备就绪,您将收到类似于以下内容的响应

{ "status": "SERVING" }

通过脚本运行推理

1. 克隆仓库

通过克隆 NVIDIA Maxine NIM Clients 仓库 下载 Maxine Studio Voice Python 客户端代码

git clone https://github.com/NVIDIA-Maxine/nim-clients.git

# Go to the 'studio-voice' folder

cd nim-clients/studio-voice/

2. 安装依赖项

sudo apt-get install python3-pip
pip install -r requirements.txt

3. 运行 Python 客户端

您可以使用 Maxine Studio Voice GitHub 仓库中的示例客户端脚本向托管的 NIM 服务器发送 gRPC 请求

  1. 转到 scripts 目录。

    cd scripts
    
  2. 运行命令以发送 gRPC 请求。

    python studio_voice.py --target <server_ip:port> --input <input_audio_file_path> --output <output_audio_file_path>
    

以下示例命令处理打包的示例音频文件,并在当前文件夹中生成 studio_voice_48k_output.wav 文件。

python studio_voice.py --target 127.0.0.1:8001 --input ../assets/studio_voice_48k_input.wav --output studio_voice_48k_output.wav

注意

仅支持 WAV 文件。

预览 API 请求的用法

python studio_voice.py --use-ssl \
    --target grpc.nvcf.nvidia.com:443 \
    --function-id <function_id> \
    --api-key $API_KEY_REQUIRED_IF_EXECUTING_OUTSIDE_NGC \
    --input <input_file_path> \
    --output <output_file_path>

命令行参数

要查看命令行参数的详细信息,请运行此命令

python studio_voice.py -h
  • --use-ssl - 用于控制是否应使用 SSL/TLS 加密的标志。 运行预览时必须使用 SSL。

  • --target <ip:port> - NIM 的 gRPC 服务的 URI。 当托管在 NVCF 上时,使用 grpc.nvcf.nvidia.com:443。 默认值为 127.0.0.1:8001

  • --api-key <NGC_API_KEY> - 身份验证所需的 NGC API 密钥。 使用 TRY API 时使用,否则忽略。

  • --function-id - 服务的 NVCF 函数 ID。 使用 TRY API 时使用,否则忽略。

  • --input - 输入音频文件的路径。 默认值为 ../assets/studio_voice_48k_input.wav

  • --output - 输出音频文件的路径。 默认为 ./studio_voice_48k_output.wav