{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# pip install tritonclient[http] ipykernel ipywidgets numpy scipy\n",
"!mkdir -p ../wavs\n",
"import numpy as np\n",
"SAMPLING_RATE = 22050\n",
"from tritonclient.utils import *\n",
"from IPython.display import Audio\n",
"from scipy.io.wavfile import write\n",
"import tritonclient.http as httpclient\n",
"triton_client = httpclient.InferenceServerClient(url=\"localhost:8011\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"source_data = np.array([['this']], dtype='object')\n",
"inputs = [httpclient.InferInput(\"INPUT_TEXT\", source_data.shape, np_to_triton_dtype(source_data.dtype)), httpclient.InferInput(\"INPUT_SPEAKER_ID\", source_data.shape, np_to_triton_dtype(source_data.dtype)), httpclient.InferInput(\"INPUT_LANGUAGE_ID\", source_data.shape, np_to_triton_dtype(source_data.dtype))]\n",
"inputs[0].set_data_from_numpy(np.array([['this is a spartfa!']], dtype='object'))\n",
"inputs[1].set_data_from_numpy(np.array([['m']], dtype='object'))\n",
"inputs[2].set_data_from_numpy(np.array([['hi']], dtype='object'))\n",
"outputs = [httpclient.InferRequestedOutput(\"OUTPUT_GENERATED_AUDIO\")]\n",
"result = triton_client.infer(model_name='tts', inputs=inputs, outputs=outputs)\n",
"result = np.frombuffer(result.as_numpy('OUTPUT_GENERATED_AUDIO')[0][0], dtype='int16')\n",
"write('../wavs/test.wav', SAMPLING_RATE, result)\n",
"display(Audio(f\"../wavs/test.wav\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "dhruva-iitm-tts",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}