{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import torch\n", "import ChatTTS\n", "from IPython.display import Audio" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d47abb2d74f4488685a4efb5da8fd791", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Fetching 10 files: 0%| | 0/10 [00:00\n", " \n", " Your browser does not support the audio element.\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Audio(wavs[0], rate=24_000, autoplay=True)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Audio(wavs[3], rate=24_000, autoplay=True)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from ChatTTS.experimental.llm import llm_api\n", "\n", "API_KEY = ''\n", "client = llm_api(api_key=API_KEY,\n", " base_url=\"https://api.deepseek.com\",\n", " model=\"deepseek-chat\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "user_question = '四川有哪些好吃的美食呢?'\n", "text = client.call(user_question, prompt_version = 'deepseek')\n", "text = client.call(text, prompt_version = 'deepseek_TN')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "spk_stat = torch.load('ChatTTS/asset/spk_stat.pt')\n", "rand_spk = torch.randn(768) * spk_stat.chunk(2)[0] + spk_stat.chunk(2)[1]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:ChatTTS.core:All initialized.\n", " 16%|█▋ | 63/384 [00:00<00:04, 77.87it/s]\n", " 26%|██▌ | 530/2048 [00:06<00:19, 78.64it/s]\n" ] } ], "source": [ "params_infer_code = {'spk_emb' : rand_spk, 'temperature':.3}\n", "params_refine_text = {'prompt':'[oral_2][laugh_0][break_6]'}\n", "# wav = chat.infer('四川美食可多了,有麻辣火锅、宫保鸡丁、麻婆豆腐、担担面、回锅肉、夫妻肺片等,每样都让人垂涎三尺。', params_refine_text=params_refine_text, params_infer_code=params_infer_code)\n", "wav = chat.infer('四川美食确实以辣闻名,但也有不辣的选择。比如甜水面、赖汤圆、蛋烘糕、叶儿粑等,这些小吃口味温和,甜而不腻,也很受欢迎。', params_refine_text=params_refine_text, params_infer_code=params_infer_code)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Audio(wav[0], rate=24_000, autoplay=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.8" } }, "nbformat": 4, "nbformat_minor": 4 }