Spaces:
Runtime error
Runtime error
File size: 6,005 Bytes
08720f3 |
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 |
# This class stores Azure voice data. Specifically, the class stores several records containing
# language, lang_code, gender, voice_id and engine. The class also has a method to return the
# voice_id, lang_code and engine given a language and gender.
NEURAL_ENGINE = "neural"
STANDARD_ENGINE = "standard"
class AzureVoiceData:
def get_voice(self, language, gender):
for voice in self.voice_data:
if voice['language'] == language and voice['gender'] == gender:
return voice['azure_voice']
return None
def __init__(self):
self.voice_data = [
{'language': 'Arabic',
'azure_voice': 'ar-EG-ShakirNeural',
'gender': 'Male'},
{'language': 'Arabic (Gulf)',
'azure_voice': 'ar-KW-FahedNeural',
'gender': 'Male'},
{'language': 'Catalan',
'azure_voice': 'ca-ES-EnricNeural',
'gender': 'Male'},
{'language': 'Chinese (Cantonese)',
'azure_voice': 'yue-CN-YunSongNeural',
'gender': 'Male'},
{'language': 'Chinese (Mandarin)',
'azure_voice': 'zh-CN-YunxiNeural',
'gender': 'Male'},
{'language': 'Danish',
'azure_voice': 'da-DK-JeppeNeural',
'gender': 'Male'},
{'language': 'Dutch',
'azure_voice': 'nl-NL-MaartenNeural',
'gender': 'Male'},
{'language': 'English (Australian)',
'azure_voice': 'en-AU-KenNeural',
'gender': 'Male'},
{'language': 'English (British)',
'azure_voice': 'en-GB-RyanNeural',
'gender': 'Male'},
{'language': 'English (Indian)',
'azure_voice': 'en-IN-PrabhatNeural',
'gender': 'Male'},
{'language': 'English (New Zealand)',
'azure_voice': 'en-NZ-MitchellNeural',
'gender': 'Male'},
{'language': 'English (South African)',
'azure_voice': 'en-ZA-LukeNeural',
'gender': 'Male'},
{'language': 'English (US)',
'azure_voice': 'en-US-ChristopherNeural',
'gender': 'Male'},
{'language': 'English (Welsh)',
'azure_voice': 'cy-GB-AledNeural',
'gender': 'Male'},
{'language': 'Finnish',
'azure_voice': 'fi-FI-HarriNeural',
'gender': 'Male'},
{'language': 'French',
'azure_voice': 'fr-FR-HenriNeural',
'gender': 'Male'},
{'language': 'French (Canadian)',
'azure_voice': 'fr-CA-AntoineNeural',
'gender': 'Male'},
{'language': 'German',
'azure_voice': 'de-DE-KlausNeural',
'gender': 'Male'},
{'language': 'German (Austrian)',
'azure_voice': 'de-AT-JonasNeural',
'gender': 'Male'},
{'language': 'Hindi',
'azure_voice': 'hi-IN-MadhurNeural',
'gender': 'Male'},
{'language': 'Icelandic',
'azure_voice': 'is-IS-GunnarNeural',
'gender': 'Male'},
{'language': 'Italian',
'azure_voice': 'it-IT-GianniNeural',
'gender': 'Male'},
{'language': 'Japanese',
'azure_voice': 'ja-JP-KeitaNeural',
'gender': 'Male'},
{'language': 'Korean',
'azure_voice': 'ko-KR-GookMinNeural',
'gender': 'Male'},
{'language': 'Norwegian',
'azure_voice': 'nb-NO-FinnNeural',
'gender': 'Male'},
{'language': 'Polish',
'azure_voice': 'pl-PL-MarekNeural',
'gender': 'Male'},
{'language': 'Portuguese (Brazilian)',
'azure_voice': 'pt-BR-NicolauNeural',
'gender': 'Male'},
{'language': 'Portuguese (European)',
'azure_voice': 'pt-PT-DuarteNeural',
'gender': 'Male'},
{'language': 'Romanian',
'azure_voice': 'ro-RO-EmilNeural',
'gender': 'Male'},
{'language': 'Russian',
'azure_voice': 'ru-RU-DmitryNeural',
'gender': 'Male'},
{'language': 'Spanish (European)',
'azure_voice': 'es-ES-TeoNeural',
'gender': 'Male'},
{'language': 'Spanish (Mexican)',
'azure_voice': 'es-MX-LibertoNeural',
'gender': 'Male'},
{'language': 'Spanish (US)',
'azure_voice': 'es-US-AlonsoNeural"',
'gender': 'Male'},
{'language': 'Swedish',
'azure_voice': 'sv-SE-MattiasNeural',
'gender': 'Male'},
{'language': 'Turkish',
'azure_voice': 'tr-TR-AhmetNeural',
'gender': 'Male'},
{'language': 'Welsh',
'azure_voice': 'cy-GB-AledNeural',
'gender': 'Male'},
]
# Run from the command-line
if __name__ == '__main__':
azure_voice_data = AzureVoiceData()
azure_voice = azure_voice_data.get_voice('English (US)', 'Male')
print('English (US)', 'Male', azure_voice)
azure_voice = azure_voice_data.get_voice('English (US)', 'Female')
print('English (US)', 'Female', azure_voice)
azure_voice = azure_voice_data.get_voice('French', 'Female')
print('French', 'Female', azure_voice)
azure_voice = azure_voice_data.get_voice('French', 'Male')
print('French', 'Male', azure_voice)
azure_voice = azure_voice_data.get_voice('Japanese', 'Female')
print('Japanese', 'Female', azure_voice)
azure_voice = azure_voice_data.get_voice('Japanese', 'Male')
print('Japanese', 'Male', azure_voice)
azure_voice = azure_voice_data.get_voice('Hindi', 'Female')
print('Hindi', 'Female', azure_voice)
azure_voice = azure_voice_data.get_voice('Hindi', 'Male')
print('Hindi', 'Male', azure_voice)
|