Skip to content

Commit b6fb204

Browse files
committed
Created using Colab
1 parent 5625286 commit b6fb204

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

Kokoro-82m-v1-demo.ipynb

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"provenance": [],
7+
"authorship_tag": "ABX9TyMEoxuP3290//xMnTcMEinL",
8+
"include_colab_link": true
9+
},
10+
"kernelspec": {
11+
"name": "python3",
12+
"display_name": "Python 3"
13+
},
14+
"language_info": {
15+
"name": "python"
16+
}
17+
},
18+
"cells": [
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {
22+
"id": "view-in-github",
23+
"colab_type": "text"
24+
},
25+
"source": [
26+
"<a href=\"https://colab.research.google.com/github/jslinuxta/Colab/blob/main/Kokoro-82m-v1-demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {
33+
"id": "tK6XGehJKYN_"
34+
},
35+
"outputs": [],
36+
"source": [
37+
"# 1️⃣ Install kokoro\n",
38+
"!pip install -q kokoro>=0.3.1 soundfile\n",
39+
"# 2️⃣ Install espeak, used for English OOD fallback and some non-English languages\n",
40+
"!apt-get -qq -y install espeak-ng > /dev/null 2>&1\n",
41+
"# 🇫🇷 'f' => French fr-fr\n",
42+
"# 🇮🇳 'h' => Hindi hi\n",
43+
"# 🇮🇹 'i' => Italian it\n",
44+
"\n",
45+
"# 3️⃣ Initalize a pipeline\n",
46+
"from kokoro import KPipeline\n",
47+
"from IPython.display import display, Audio\n",
48+
"import soundfile as sf\n",
49+
"# 🇺🇸 'a' => American English, 🇬🇧 'b' => British English\n",
50+
"# 🇯🇵 'j' => Japanese: pip install misaki[ja]\n",
51+
"# 🇨🇳 'z' => Mandarin Chinese: pip install misaki[zh]\n",
52+
"pipeline = KPipeline(lang_code='a') # <= make sure lang_code matches voice\n",
53+
"\n",
54+
"# This text is for demonstration purposes only, unseen during training\n",
55+
"text = '''\n",
56+
"The sky above the port was the color of television, tuned to a dead channel.\n",
57+
"\"It's not like I'm using,\" Case heard someone say, as he shouldered his way through the crowd around the door of the Chat. \"It's like my body's developed this massive drug deficiency.\"\n",
58+
"It was a Sprawl voice and a Sprawl joke. The Chatsubo was a bar for professional expatriates; you could drink there for a week and never hear two words in Japanese.\n",
59+
"\n",
60+
"These were to have an enormous impact, not only because they were associated with Constantine, but also because, as in so many other areas, the decisions taken by Constantine (or in his name) were to have great significance for centuries to come. One of the main issues was the shape that Christian churches were to take, since there was not, apparently, a tradition of monumental church buildings when Constantine decided to help the Christian church build a series of truly spectacular structures. The main form that these churches took was that of the basilica, a multipurpose rectangular structure, based ultimately on the earlier Greek stoa, which could be found in most of the great cities of the empire. Christianity, unlike classical polytheism, needed a large interior space for the celebration of its religious services, and the basilica aptly filled that need. We naturally do not know the degree to which the emperor was involved in the design of new churches, but it is tempting to connect this with the secular basilica that Constantine completed in the Roman forum (the so-called Basilica of Maxentius) and the one he probably built in Trier, in connection with his residence in the city at a time when he was still caesar.\n",
61+
"'''\n",
62+
"# text = '「もしおれがただ偶然、そしてこうしようというつもりでなくここに立っているのなら、ちょっとばかり絶望するところだな」と、そんなことが彼の頭に思い浮かんだ。'\n",
63+
"# text = '中國人民不信邪也不怕邪,不惹事也不怕事,任何外國不要指望我們會拿自己的核心利益做交易,不要指望我們會吞下損害我國主權、安全、發展利益的苦果!'\n",
64+
"# text = 'Le dromadaire resplendissant déambulait tranquillement dans les méandres en mastiquant de petites feuilles vernissées.'\n",
65+
"# text = 'ट्रांसपोर्टरों की हड़ताल लगातार पांचवें दिन जारी, दिसंबर से इलेक्ट्रॉनिक टोल कलेक्शनल सिस्टम'\n",
66+
"# text = \"Allora cominciava l'insonnia, o un dormiveglia peggiore dell'insonnia, che talvolta assumeva i caratteri dell'incubo.\"\n",
67+
"\n",
68+
"# 4️⃣ Generate, display, and save audio files in a loop.\n",
69+
"generator = pipeline(\n",
70+
" text, voice='af_bella', # <= change voice here\n",
71+
" speed=1, split_pattern=r'\\n+'\n",
72+
")\n",
73+
"for i, (gs, ps, audio) in enumerate(generator):\n",
74+
" print(i) # i => index\n",
75+
" print(gs) # gs => graphemes/text\n",
76+
" print(ps) # ps => phonemes\n",
77+
" display(Audio(data=audio, rate=24000, autoplay=i==0))\n",
78+
" sf.write(f'{i}.wav', audio, 24000) # save each audio file\n"
79+
]
80+
}
81+
]
82+
}

0 commit comments

Comments
 (0)