File size: 14,606 Bytes
5895355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# French SSML Cascade Models Demo\n",
        "\n",
        "<img src=\"https://www.hi-paris.fr/wp-content/uploads/2020/09/logo-hi-paris-retina.png\" alt=\"Hi! Paris\" width=\"200\"/>\n",
        "\n",
        "**Interactive demonstration of French SSML cascade models for improved text-to-speech prosody control.**\n",
        "\n",
        "This notebook demonstrates the complete pipeline from plain French text to rich SSML markup with prosody control.\n",
        "\n",
        "## 🧩 Pipeline Overview\n",
        "\n",
        "1. **Text-to-Breaks**: Predicts natural pause locations  \n",
        "2. **Breaks-to-SSML**: Adds prosody control (pitch, rate, volume) and precise timing\n",
        "\n",
        "📄 **Paper**: *Improving Synthetic Speech Quality via SSML Prosody Control* (ICNLSP 2025)  \n",
        "🔗 **Demo & Audio Samples**: https://horstmann.tech/ssml-prosody-control/  \n",
        "📚 **Models**: [hi-paris/ssml-text2breaks-fr-lora](https://huggingface.co/hi-paris/ssml-text2breaks-fr-lora) • [hi-paris/ssml-breaks2ssml-fr-lora](https://huggingface.co/hi-paris/ssml-breaks2ssml-fr-lora)\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 🚀 Setup\n",
        "\n",
        "### Step 1: Mount Google Drive"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 34,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "a1jNj9uK7EoL",
        "outputId": "76624289-061f-4700-e397-50da9da9ee6d"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ],
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive', force_remount=True)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Step 2: Clone Repository"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 35,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "eE3iUaX_7OLG",
        "outputId": "d621b296-b12f-489a-bc1f-c7240c21646b"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory\n",
            "chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory\n",
            "Cloning into 'cascading_model'...\n"
          ]
        }
      ],
      "source": [
        "%%bash\n",
        "cd /content/drive/MyDrive/\n",
        "git clone https://github.com/TimLukaHorstmann/cascading_model.git"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 36,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "vItNbMvh7ZNL",
        "outputId": "31a31144-1261-4427-9d2e-089ae17689b2"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "/content/drive/MyDrive/cascading_model\n"
          ]
        }
      ],
      "source": [
        "%cd /content/drive/MyDrive/cascading_model/\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 37,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "JdeuCOX_7kae",
        "outputId": "f8bad5e1-92d0-4531-fbe0-ca2f29a8efd8"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "breaks2ssml_inference.py\n",
            "demo.py\n",
            "empty_ssml_creation.py\n",
            "__init__.py\n",
            "pyproject.toml\n",
            "README.md\n",
            "requirements.txt\n",
            "shared_models.py\n",
            "test_models.py\n",
            "text2breaks_inference.py\n"
          ]
        }
      ],
      "source": [
        "%%bash\n",
        "ls"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 🧪 Testing & Demo\n",
        "\n",
        "### Step 3: Verify Installation"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 38,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "eaBx_eh-819B",
        "outputId": "2c55f4fa-f17e-49b8-b032-74d670dcd34a"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "2025-08-06 12:36:48.453347: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
            "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
            "E0000 00:00:1754483808.475278   35366 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
            "E0000 00:00:1754483808.481612   35366 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
            "============================================================\n",
            "🧪 French SSML Models - Test Suite\n",
            "============================================================\n",
            "🔍 Testing imports...\n",
            "   ✅ PyTorch 2.5.1+cu121\n",
            "   ✅ Transformers 4.54.0\n",
            "   ✅ PEFT 0.16.0\n",
            "   ✅ All imports successful!\n",
            "\n",
            "🔧 Testing model loading...\n",
            "   Loading text2breaks model...\n",
            "Loading checkpoint shards: 100% 4/4 [01:33<00:00, 23.46s/it]\n",
            "   ✅ Text2breaks model loaded\n",
            "   Loading breaks2ssml model...\n",
            "   ✅ Breaks2ssml model loaded\n",
            "   ✅ All models loaded successfully!\n",
            "\n",
            "🧪 Testing inference...\n",
            "   Input: Bonjour comment allez-vous ?\n",
            "   Testing text2breaks...\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "   Step 1 result: Bonjour comment allez-vous ?<break/>\n",
            "   Testing breaks2ssml...\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "   Step 2 result: <prosody pitch=\"+0.64%\" rate=\"-1.92%\" volume=\"-10.00%\">\n",
            "    Bonjour comment allez-vous ?\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "   ✅ Inference test successful!\n",
            "\n",
            "🔗 Testing full cascade...\n",
            "   Input: Bonsoir comment ça va ?\n",
            "   Cascade result: <prosody pitch=\"+0.64%\" rate=\"-1.92%\" volume=\"-10.00%\">\n",
            "    Bonsoir comment ça va ?\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "   ✅ Cascade test successful!\n",
            "\n",
            "============================================================\n",
            "🎉 All tests passed! The models are working correctly.\n",
            "============================================================\n",
            "\n",
            "You can now use:\n",
            "  - python demo.py (for examples)\n",
            "  - python demo.py --interactive (for interactive mode)\n",
            "  - python text2breaks_inference.py --interactive\n",
            "  - python breaks2ssml_inference.py --interactive\n"
          ]
        }
      ],
      "source": [
        "!python test_models.py"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Step 4: Interactive Demo\n",
        "\n",
        "Run the interactive demo to test the models with your own French text:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ZIeUY9atUhvV",
        "outputId": "581f1395-fa70-424f-9c66-50b5e44547c3"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "2025-08-06 12:21:35.541051: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
            "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
            "E0000 00:00:1754482895.561958   31169 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
            "E0000 00:00:1754482895.568312   31169 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
            "================================================================================\n",
            "Interactive French SSML Cascade\n",
            "================================================================================\n",
            "\n",
            "Choose mode:\n",
            "1. Full cascade (text → breaks → SSML)\n",
            "2. Text to breaks only\n",
            "3. Breaks to SSML only\n",
            "\n",
            "Select mode (1-3): 1\n",
            "\n",
            "Initializing models...\n",
            "Loading checkpoint shards: 100% 4/4 [01:30<00:00, 22.70s/it]\n",
            "Models loaded successfully!\n",
            "\n",
            "Enter French text (empty line to exit):\n",
            "\n",
            "> Je suis Luka.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "Output: <prosody pitch=\"+0.64%\" rate=\"-1.92%\" volume=\"-10.00%\">\n",
            "    Je suis Luka.\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "Time: 6.55s\n",
            "\n",
            "> Trés bien.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "Output: <prosody pitch=\"+0.64%\" rate=\"-1.92%\" volume=\"-10.00%\">\n",
            "    Trés bien.\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "Time: 5.64s\n",
            "\n",
            "> Je suis Bertrand Perier. Je suis avocat et vous écoutez ma masterclass.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.\n",
            "Output: <prosody pitch=\"+0.64%\" rate=\"-1.92%\" volume=\"-10.00%\">\n",
            "    Je suis Bertrand Perier.\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "\n",
            "  <prosody pitch=\"+3.78%\" rate=\"-1.29%\" volume=\"-10.00%\">\n",
            "    Je suis avocat et vous écoutez ma masterclass.\n",
            "  </prosody>\n",
            "  <break time=\"500ms\"/>\n",
            "Time: 12.11s\n",
            "\n",
            "> Exception ignored in: <module 'threading' from '/usr/lib/python3.11/threading.py'>\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/lib/python3.11/threading.py\", line 1541, in _shutdown\n",
            "    def _shutdown():\n",
            "    \n",
            "KeyboardInterrupt: \n"
          ]
        }
      ],
      "source": [
        "!python demo.py --interactive"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 🎯 Example Usage\n",
        "\n",
        "```python\n",
        "from breaks2ssml_inference import CascadedInference\n",
        "\n",
        "# Initialize the full cascade\n",
        "cascade = CascadedInference()\n",
        "\n",
        "# Convert plain French text to SSML\n",
        "text = \"Bonjour comment allez-vous aujourd'hui ?\"\n",
        "result = cascade.predict(text)\n",
        "print(result)\n",
        "```\n",
        "\n",
        "**Expected Output:**\n",
        "```xml\n",
        "<prosody pitch=\"+2.5%\" rate=\"-1.2%\" volume=\"-5.0%\">Bonjour comment allez-vous aujourd'hui ?</prosody><break time=\"300ms\"/>\n",
        "```\n",
        "\n",
        "## 📚 Resources\n",
        "\n",
        "- **Audio Demos**: https://horstmann.tech/ssml-prosody-control/\n",
        "- **GitHub Repository**: https://github.com/TimLukaHorstmann/cascading_model\n",
        "- **Stage 1 Model**: https://huggingface.co/hi-paris/ssml-text2breaks-fr-lora\n",
        "- **Stage 2 Model**: https://huggingface.co/hi-paris/ssml-breaks2ssml-fr-lora\n",
        "\n",
        "---\n",
        "*Hi! Paris - Interdisciplinary Research Institute for Artificial Intelligence*"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": []
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "gpuType": "T4",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}