summaryrefslogtreecommitdiff
path: root/python-audio-program-generator.spec
blob: 17732541f15616eceb87e9caf2f7f4e90e388617 (plain)
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
%global _empty_manifest_terminate_build 0
Name:		python-audio-program-generator
Version:	1.12.1
Release:	1
Summary:	Create an audio program from a text file containing English sentences
License:	MIT
URL:		https://github.com/jeffwright13/audio_program_generator/
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/5a/3b/6a47a65861a7d7ab656999458c729899f2321f600557989a084a4063d28f/audio_program_generator-1.12.1.tar.gz
BuildArch:	noarch

Requires:	python3-alive-progress
Requires:	python3-gTTS
Requires:	python3-pydub
Requires:	python3-sentence-splitter
Requires:	python3-single-source
Requires:	python3-typer

%description

[![Python package](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml)
[![CodeQL](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml)

# apg (audio_program_generator)
Generates an audio program from text, with option to mix in background sound

Possible use cases:
- make your own yoga or qi gong routine
- play a list of daily affirmations
- meditate to a mantra with drone music in the background
- create an audio book
- read a kid a bedtime story without actually having to do the reading

# Basic Usage
#### (see 'Detailed Usage' below for more info)
```
Usage: apg [OPTIONS] PHRASE_PATH [SOUND_PATH]

Arguments:
  PHRASE_PATH   Absolute or relative path to phrase file.  [required]
  [SOUND_PATH]  Path to .wav file to mix with generated speech. [optional]

Options:
  -o, --output-path PATH          Path to store resulting audio file.
  -f, --format, --output-format [wav|mp3|ogg|aac|flac]
                                  File format for output file.  [default: wav]
  -a, --attenuation INTEGER       Set background file attenuation in dB.
                                  [default: 0]
  --fi, --fadein INTEGER          Set fade-in duration in milliseconds.
                                  [default: 3000]
  --fo, --fadeout INTEGER         Set fade-out duration in milliseconds.
                                  [default: 6000]
  -s, --slow                      Generate speech at half-speed.
  -r, --region [AU|CA|IE|IN|UK|US|ZA]
                                  Regional accent to apply to generated
                                  speech.  [default: US]
  -b, --book-mode                 Operates on plain-text file without
                                  phrase/pause formatting.
  -H, --hide, --hide-progress-bar
                                  Do not display progress bar during
                                  execution.
  -v, --version                   Show version and exit.
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  -h, --help                      Show this message and exit.
```

# Prerequisites
Either:
 * Python (3.7+)
 * [pip](https://pypi.org/project/pip/) (option 1)
 * [git](https://git-scm.com/) + [poetry](https://python-poetry.org/) (option 2)
 * Local installation of [ffmpeg](https://www.ffmpeg.org/) (to save results in formats other than .wav)

Or:
 * [docker](https://www.docker.com/)

# Installation & Execution
## With `pip`:
- Create a virtual environment and activate it:
    - `python -m venv venv`
    - `source ./venv/bin/activate`
 - Install the package:
    - `pip install audio-program-generator`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Deactivate your virtual environment when finished:
    - `deactivate`

## With `poetry`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Install the dependencies using poetry, and activate the virtual environment:
    - `poetry install --no-dev`
    - `poetry shell`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Exit the poetry virtual environment when finished:
    - `exit`

## With `docker`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Execute `make apg-build` (builds Docker image)
- Place your <phrase_file> and any <sound_file> in the `apgfiles` subdirectory; docker will be looking for them there
- Execute `make apg args=<args>` (runs container with specified arguments; if using multiple arguments, wrap them all in quotes)
- Results from `make apg` will be available locally in the `/apgfiles` folder, even after the container is stopped
- Examples:
    - `make apg args=--help`
    - `make apg args=-V`
    - `make apg args="apgfiles/program.txt apgfiles/river.wav -a 0 -t co.in"`
    - `make apg args="apgfiles/program.txt -slow -t co.in"`

## With `flask`:
- There is a [sister project](https://github.com/jeffwright13/apg_flask) that wraps the apg module in a bare-bones Flask app. This can be hosted locally, or in a cloud provider such as Heroku, Digital Ocean, or AWS. This method is considered experimental at the moment, and is not officially supported.

# Detailed Usage
*Assumes you are using the provided `apg` command line interface, installed with one of the methods above.  Refer to the source code if you are importing this code as a module/package.*

- Populate a semicolon-separated text file with plain-text phrases, each followed by an inter-phrase duration (see example below). Each line of the file is comprised of:
   - a phrase to be spoken (in English) *or* an asterisk to indicate silence
   - a semicolon
   - a silence duration (in seconds)
- Provide a sound file for background sound (optional)
- Execute the command: `apg [options] <phrase_file> [sound_file]`

The script will generate and save a single audio file. The base name of the file will be the same as the specified input file. The output file will be saved to the same folder that the input text file was taken from, unless specified otherwise (using the "-o" option). For example, if the script is given input file "phrases.txt", the output file will be "phrases.wav" or "phrases.mp3"  or whatever the output format is set to be (using the "-f" option, which defults to ".wav").

The optional `[sound_file]` parameter, when specified, is used to mix in background sounds/music. This parameter specifies the path/filename of the sound file to be mixed in with the speech generated from the phrase file. If the sound file is shorter in duration than the generated speech file, it will be looped. If it is longer, it will be truncated. The resulting background sound (looped or not) will be faded in and out to ensure a smooth transition (6 seconds at beginning and en). Currently, only .wav files are supported as inputs.

The CLI prints out a progress bar by default. The progress bar may be disabled with the `--no-progress-bar` option.

The `--attenuation` option allows fine-tuning the background sound level so it doesn't drown out the generated speech.

The `--slow` option generates each speech snippet is a slow-spoken style.

The `--tld` option allows the user to select one of several regional 'accents' (English only). For accents, select one from the following list: ["com.au", "co.uk", "com", "ca", "co.in", "ie", "co.za"]

Specifying option `--book-mode` creates a spoken-word program (with or without background soundfile). It does this by reading in a file that does not have inter-phrase durations inserted, as is normally the case.

# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three").

    Phrase One;2
    Phrase Two;5
    Phrase Three;0
    
# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three"), with a 3-second silence snippet appearing at the beginning.

    *; 3
    Phrase One; 2
    Phrase Two; 5
    Phrase Three; 0

# Example `--book-mode` file format
    Here we have sentence number one (which is a lovely sentence, and deserves its own paragraph).

    Here is a second paragraph, and this is sentence number one (again) in that paragraph. And this is sentence number two! Then shalt thou count to three - no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in my sight, shall snuff it.

# Testing
Tests are implemented in pytest. You don't really need to worry about that if all you want to do it run them, but chances are if you want to run them, you're probably some sort of a hacker or coder or programmer, and you want to know the deets. See the [source code](https://github.com/jeffwright13/audio_program_generator/tree/main/tests) for more info.

To execute the tests, do one of the following:
* Fire up your venv (see Installation & Execution section above), cd into the top level of the repo, and type `pytest`.

* Do basically the same thing with poetry:

    `poetry shell`

    `pytest`

* Use docker:

    `make apg-build-test`

    `make test`

# Author:
Jeff Wright <jeff.washcloth@gmail.com>

# Collaborators:
- Bob Belderbos
- Erik OShaughnessy



%package -n python3-audio-program-generator
Summary:	Create an audio program from a text file containing English sentences
Provides:	python-audio-program-generator
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-audio-program-generator

[![Python package](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml)
[![CodeQL](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml)

# apg (audio_program_generator)
Generates an audio program from text, with option to mix in background sound

Possible use cases:
- make your own yoga or qi gong routine
- play a list of daily affirmations
- meditate to a mantra with drone music in the background
- create an audio book
- read a kid a bedtime story without actually having to do the reading

# Basic Usage
#### (see 'Detailed Usage' below for more info)
```
Usage: apg [OPTIONS] PHRASE_PATH [SOUND_PATH]

Arguments:
  PHRASE_PATH   Absolute or relative path to phrase file.  [required]
  [SOUND_PATH]  Path to .wav file to mix with generated speech. [optional]

Options:
  -o, --output-path PATH          Path to store resulting audio file.
  -f, --format, --output-format [wav|mp3|ogg|aac|flac]
                                  File format for output file.  [default: wav]
  -a, --attenuation INTEGER       Set background file attenuation in dB.
                                  [default: 0]
  --fi, --fadein INTEGER          Set fade-in duration in milliseconds.
                                  [default: 3000]
  --fo, --fadeout INTEGER         Set fade-out duration in milliseconds.
                                  [default: 6000]
  -s, --slow                      Generate speech at half-speed.
  -r, --region [AU|CA|IE|IN|UK|US|ZA]
                                  Regional accent to apply to generated
                                  speech.  [default: US]
  -b, --book-mode                 Operates on plain-text file without
                                  phrase/pause formatting.
  -H, --hide, --hide-progress-bar
                                  Do not display progress bar during
                                  execution.
  -v, --version                   Show version and exit.
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  -h, --help                      Show this message and exit.
```

# Prerequisites
Either:
 * Python (3.7+)
 * [pip](https://pypi.org/project/pip/) (option 1)
 * [git](https://git-scm.com/) + [poetry](https://python-poetry.org/) (option 2)
 * Local installation of [ffmpeg](https://www.ffmpeg.org/) (to save results in formats other than .wav)

Or:
 * [docker](https://www.docker.com/)

# Installation & Execution
## With `pip`:
- Create a virtual environment and activate it:
    - `python -m venv venv`
    - `source ./venv/bin/activate`
 - Install the package:
    - `pip install audio-program-generator`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Deactivate your virtual environment when finished:
    - `deactivate`

## With `poetry`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Install the dependencies using poetry, and activate the virtual environment:
    - `poetry install --no-dev`
    - `poetry shell`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Exit the poetry virtual environment when finished:
    - `exit`

## With `docker`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Execute `make apg-build` (builds Docker image)
- Place your <phrase_file> and any <sound_file> in the `apgfiles` subdirectory; docker will be looking for them there
- Execute `make apg args=<args>` (runs container with specified arguments; if using multiple arguments, wrap them all in quotes)
- Results from `make apg` will be available locally in the `/apgfiles` folder, even after the container is stopped
- Examples:
    - `make apg args=--help`
    - `make apg args=-V`
    - `make apg args="apgfiles/program.txt apgfiles/river.wav -a 0 -t co.in"`
    - `make apg args="apgfiles/program.txt -slow -t co.in"`

## With `flask`:
- There is a [sister project](https://github.com/jeffwright13/apg_flask) that wraps the apg module in a bare-bones Flask app. This can be hosted locally, or in a cloud provider such as Heroku, Digital Ocean, or AWS. This method is considered experimental at the moment, and is not officially supported.

# Detailed Usage
*Assumes you are using the provided `apg` command line interface, installed with one of the methods above.  Refer to the source code if you are importing this code as a module/package.*

- Populate a semicolon-separated text file with plain-text phrases, each followed by an inter-phrase duration (see example below). Each line of the file is comprised of:
   - a phrase to be spoken (in English) *or* an asterisk to indicate silence
   - a semicolon
   - a silence duration (in seconds)
- Provide a sound file for background sound (optional)
- Execute the command: `apg [options] <phrase_file> [sound_file]`

The script will generate and save a single audio file. The base name of the file will be the same as the specified input file. The output file will be saved to the same folder that the input text file was taken from, unless specified otherwise (using the "-o" option). For example, if the script is given input file "phrases.txt", the output file will be "phrases.wav" or "phrases.mp3"  or whatever the output format is set to be (using the "-f" option, which defults to ".wav").

The optional `[sound_file]` parameter, when specified, is used to mix in background sounds/music. This parameter specifies the path/filename of the sound file to be mixed in with the speech generated from the phrase file. If the sound file is shorter in duration than the generated speech file, it will be looped. If it is longer, it will be truncated. The resulting background sound (looped or not) will be faded in and out to ensure a smooth transition (6 seconds at beginning and en). Currently, only .wav files are supported as inputs.

The CLI prints out a progress bar by default. The progress bar may be disabled with the `--no-progress-bar` option.

The `--attenuation` option allows fine-tuning the background sound level so it doesn't drown out the generated speech.

The `--slow` option generates each speech snippet is a slow-spoken style.

The `--tld` option allows the user to select one of several regional 'accents' (English only). For accents, select one from the following list: ["com.au", "co.uk", "com", "ca", "co.in", "ie", "co.za"]

Specifying option `--book-mode` creates a spoken-word program (with or without background soundfile). It does this by reading in a file that does not have inter-phrase durations inserted, as is normally the case.

# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three").

    Phrase One;2
    Phrase Two;5
    Phrase Three;0
    
# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three"), with a 3-second silence snippet appearing at the beginning.

    *; 3
    Phrase One; 2
    Phrase Two; 5
    Phrase Three; 0

# Example `--book-mode` file format
    Here we have sentence number one (which is a lovely sentence, and deserves its own paragraph).

    Here is a second paragraph, and this is sentence number one (again) in that paragraph. And this is sentence number two! Then shalt thou count to three - no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in my sight, shall snuff it.

# Testing
Tests are implemented in pytest. You don't really need to worry about that if all you want to do it run them, but chances are if you want to run them, you're probably some sort of a hacker or coder or programmer, and you want to know the deets. See the [source code](https://github.com/jeffwright13/audio_program_generator/tree/main/tests) for more info.

To execute the tests, do one of the following:
* Fire up your venv (see Installation & Execution section above), cd into the top level of the repo, and type `pytest`.

* Do basically the same thing with poetry:

    `poetry shell`

    `pytest`

* Use docker:

    `make apg-build-test`

    `make test`

# Author:
Jeff Wright <jeff.washcloth@gmail.com>

# Collaborators:
- Bob Belderbos
- Erik OShaughnessy



%package help
Summary:	Development documents and examples for audio-program-generator
Provides:	python3-audio-program-generator-doc
%description help

[![Python package](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/python-package.yml)
[![CodeQL](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jeffwright13/audio_program_generator/actions/workflows/codeql-analysis.yml)

# apg (audio_program_generator)
Generates an audio program from text, with option to mix in background sound

Possible use cases:
- make your own yoga or qi gong routine
- play a list of daily affirmations
- meditate to a mantra with drone music in the background
- create an audio book
- read a kid a bedtime story without actually having to do the reading

# Basic Usage
#### (see 'Detailed Usage' below for more info)
```
Usage: apg [OPTIONS] PHRASE_PATH [SOUND_PATH]

Arguments:
  PHRASE_PATH   Absolute or relative path to phrase file.  [required]
  [SOUND_PATH]  Path to .wav file to mix with generated speech. [optional]

Options:
  -o, --output-path PATH          Path to store resulting audio file.
  -f, --format, --output-format [wav|mp3|ogg|aac|flac]
                                  File format for output file.  [default: wav]
  -a, --attenuation INTEGER       Set background file attenuation in dB.
                                  [default: 0]
  --fi, --fadein INTEGER          Set fade-in duration in milliseconds.
                                  [default: 3000]
  --fo, --fadeout INTEGER         Set fade-out duration in milliseconds.
                                  [default: 6000]
  -s, --slow                      Generate speech at half-speed.
  -r, --region [AU|CA|IE|IN|UK|US|ZA]
                                  Regional accent to apply to generated
                                  speech.  [default: US]
  -b, --book-mode                 Operates on plain-text file without
                                  phrase/pause formatting.
  -H, --hide, --hide-progress-bar
                                  Do not display progress bar during
                                  execution.
  -v, --version                   Show version and exit.
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  -h, --help                      Show this message and exit.
```

# Prerequisites
Either:
 * Python (3.7+)
 * [pip](https://pypi.org/project/pip/) (option 1)
 * [git](https://git-scm.com/) + [poetry](https://python-poetry.org/) (option 2)
 * Local installation of [ffmpeg](https://www.ffmpeg.org/) (to save results in formats other than .wav)

Or:
 * [docker](https://www.docker.com/)

# Installation & Execution
## With `pip`:
- Create a virtual environment and activate it:
    - `python -m venv venv`
    - `source ./venv/bin/activate`
 - Install the package:
    - `pip install audio-program-generator`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Deactivate your virtual environment when finished:
    - `deactivate`

## With `poetry`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Install the dependencies using poetry, and activate the virtual environment:
    - `poetry install --no-dev`
    - `poetry shell`
- Once this is done, you will have an "apg" executable available in your terminal. You can type `apg` for basic help, or `apg --help` for full instructions.
- Exit the poetry virtual environment when finished:
    - `exit`

## With `docker`:
- Clone the repo and cd into the directory:
    - `git clone https://github.com/jeffwright13/audio_program_generator.git`
    - `cd audio_program_generator`
- Execute `make apg-build` (builds Docker image)
- Place your <phrase_file> and any <sound_file> in the `apgfiles` subdirectory; docker will be looking for them there
- Execute `make apg args=<args>` (runs container with specified arguments; if using multiple arguments, wrap them all in quotes)
- Results from `make apg` will be available locally in the `/apgfiles` folder, even after the container is stopped
- Examples:
    - `make apg args=--help`
    - `make apg args=-V`
    - `make apg args="apgfiles/program.txt apgfiles/river.wav -a 0 -t co.in"`
    - `make apg args="apgfiles/program.txt -slow -t co.in"`

## With `flask`:
- There is a [sister project](https://github.com/jeffwright13/apg_flask) that wraps the apg module in a bare-bones Flask app. This can be hosted locally, or in a cloud provider such as Heroku, Digital Ocean, or AWS. This method is considered experimental at the moment, and is not officially supported.

# Detailed Usage
*Assumes you are using the provided `apg` command line interface, installed with one of the methods above.  Refer to the source code if you are importing this code as a module/package.*

- Populate a semicolon-separated text file with plain-text phrases, each followed by an inter-phrase duration (see example below). Each line of the file is comprised of:
   - a phrase to be spoken (in English) *or* an asterisk to indicate silence
   - a semicolon
   - a silence duration (in seconds)
- Provide a sound file for background sound (optional)
- Execute the command: `apg [options] <phrase_file> [sound_file]`

The script will generate and save a single audio file. The base name of the file will be the same as the specified input file. The output file will be saved to the same folder that the input text file was taken from, unless specified otherwise (using the "-o" option). For example, if the script is given input file "phrases.txt", the output file will be "phrases.wav" or "phrases.mp3"  or whatever the output format is set to be (using the "-f" option, which defults to ".wav").

The optional `[sound_file]` parameter, when specified, is used to mix in background sounds/music. This parameter specifies the path/filename of the sound file to be mixed in with the speech generated from the phrase file. If the sound file is shorter in duration than the generated speech file, it will be looped. If it is longer, it will be truncated. The resulting background sound (looped or not) will be faded in and out to ensure a smooth transition (6 seconds at beginning and en). Currently, only .wav files are supported as inputs.

The CLI prints out a progress bar by default. The progress bar may be disabled with the `--no-progress-bar` option.

The `--attenuation` option allows fine-tuning the background sound level so it doesn't drown out the generated speech.

The `--slow` option generates each speech snippet is a slow-spoken style.

The `--tld` option allows the user to select one of several regional 'accents' (English only). For accents, select one from the following list: ["com.au", "co.uk", "com", "ca", "co.in", "ie", "co.za"]

Specifying option `--book-mode` creates a spoken-word program (with or without background soundfile). It does this by reading in a file that does not have inter-phrase durations inserted, as is normally the case.

# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three").

    Phrase One;2
    Phrase Two;5
    Phrase Three;0
    
# Example `<phrase_file>` file format
This example will generate a speech-file that has 3 speech snippets ("Phrase One", "Phrase Two", "Phrase Three"), with a 3-second silence snippet appearing at the beginning.

    *; 3
    Phrase One; 2
    Phrase Two; 5
    Phrase Three; 0

# Example `--book-mode` file format
    Here we have sentence number one (which is a lovely sentence, and deserves its own paragraph).

    Here is a second paragraph, and this is sentence number one (again) in that paragraph. And this is sentence number two! Then shalt thou count to three - no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in my sight, shall snuff it.

# Testing
Tests are implemented in pytest. You don't really need to worry about that if all you want to do it run them, but chances are if you want to run them, you're probably some sort of a hacker or coder or programmer, and you want to know the deets. See the [source code](https://github.com/jeffwright13/audio_program_generator/tree/main/tests) for more info.

To execute the tests, do one of the following:
* Fire up your venv (see Installation & Execution section above), cd into the top level of the repo, and type `pytest`.

* Do basically the same thing with poetry:

    `poetry shell`

    `pytest`

* Use docker:

    `make apg-build-test`

    `make test`

# Author:
Jeff Wright <jeff.washcloth@gmail.com>

# Collaborators:
- Bob Belderbos
- Erik OShaughnessy



%prep
%autosetup -n audio-program-generator-1.12.1

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-audio-program-generator -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue May 30 2023 Python_Bot <Python_Bot@openeuler.org> - 1.12.1-1
- Package Spec generated