~kf5jwc/garretts-plugin-google

ref: 9b0537b41a1155ed919fae5d63e458c8b6f4a7fa garretts-plugin-google/garretts_plugin_google/__init__.py -rw-r--r-- 2.5 KiB
9b0537b4 — Kyle Jones Rename to GarreTTS 1 year, 11 months ago
                                                                                
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
"""A plugin for text_synthesizer, supporting google as a synthesizer."""

__version__ = "0.1.0"

import os as __os
from typing import BinaryIO as __BinaryIO

from text_synthesizer import Plugin as __plugin, Type as __Type

from .plugin_files import credentials_file as __credentials_file
from .google import synthesize_text as __synthesize
from .exception_handler import exception_catcher as __exception_catcher


# Load the credentials file into the env where TTS expects
__os.environ[__credentials_file] = str(__Type.plugin_file(__credentials_file))


# Standard
@__plugin.register(name="Google Standard A")
@__exception_catcher
def standard_a(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-A")


@__plugin.register(name="Google Standard B")
@__exception_catcher
def standard_b(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-B")


@__plugin.register(name="Google Standard C")
@__exception_catcher
def standard_c(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-C")


@__plugin.register(name="Google Standard D")
@__exception_catcher
def standard_d(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-D")


@__plugin.register(name="Google Standard E")
@__exception_catcher
def standard_e(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-E")


@__plugin.register(name="Google Standard F")
@__exception_catcher
def standard_f(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Standard-F")


# Wavenet
@__plugin.register(name="Google Wavenet A")
@__exception_catcher
def wavenet_a(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-A")


@__plugin.register(name="Google Wavenet B")
@__exception_catcher
def wavenet_b(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-B")


@__plugin.register(name="Google Wavenet C")
@__exception_catcher
def wavenet_c(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-C")


@__plugin.register(name="Google Wavenet D")
@__exception_catcher
def wavenet_d(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-D")


@__plugin.register(name="Google Wavenet E")
@__exception_catcher
def wavenet_e(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-E")


@__plugin.register(name="Google Wavenet F")
@__exception_catcher
def wavenet_f(text: str) -> __BinaryIO:
    return __synthesize(text, name="en-US-Wavenet-F")