{ "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": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:ChatTTS.core:Load from local: /home/u210110703/.cache/modelscope/hub/pzc163/chatTTS\n", "INFO:ChatTTS.core:use cuda:0\n", "INFO:ChatTTS.core:vocos loaded.\n", "INFO:ChatTTS.core:dvae loaded.\n", "INFO:ChatTTS.core:gpt loaded.\n", "INFO:ChatTTS.core:decoder loaded.\n", "INFO:ChatTTS.core:tokenizer loaded.\n", "INFO:ChatTTS.core:All initialized.\n" ] } ], "source": [ "chat = ChatTTS.Chat()\n", "chat.load_models(source = \"local\", local_path='/home/u210110703/.cache/modelscope/hub/pzc163/chatTTS')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "texts = [\"So we found being competitive and collaborative was a huge way of staying motivated towards our goals, so one person to call when you fall off, one person who gets you back on then one person to actually do the activity with.\",]*3 \\\n", " + [\"我觉得像我们这些写程序的人,他,我觉得多多少少可能会对开源有一种情怀在吧我觉得开源是一个很好的形式。现在其实最先进的技术掌握在一些公司的手里的话,就他们并不会轻易的开放给所有的人用。\"]*3 " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:ChatTTS.core:All initialized.\n", " 28%|██▊ | 109/384 [00:11<00:27, 9.88it/s]\n", " 47%|████▋ | 971/2048 [00:15<00:17, 61.34it/s]\n", "/home/u210110703/.conda/envs/chat-tts/lib/python3.10/site-packages/torch/nn/modules/conv.py:306: UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR: cudnnFinalize Descriptor Failed cudnn_status: CUDNN_STATUS_NOT_SUPPORTED (Triggered internally at ../aten/src/ATen/native/cudnn/Conv_v8.cpp:919.)\n", " return F.conv1d(input, weight, bias, self.stride,\n" ] } ], "source": [ "wavs = chat.infer(texts, use_decoder=True)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\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.14" } }, "nbformat": 4, "nbformat_minor": 4 }