cloudlanguagetools 6.8__tar.gz → 7.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/PKG-INFO +1 -1
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/elevenlabs.py +12 -1
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/languages.py +6 -5
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/naver.py +46 -24
- cloudlanguagetools-7.0/cloudlanguagetools/openai.py +206 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/PKG-INFO +1 -1
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/requires.txt +1 -1
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/setup.py +2 -2
- cloudlanguagetools-6.8/cloudlanguagetools/openai.py +0 -72
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/LICENSE +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/README.rst +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/__init__.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/amazon.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/argostranslate.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/azure.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/cereproc.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/chatapi.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/constants.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/deepl.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/dictionarylookup.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/easypronunciation.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/encryption.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/epitran.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/errors.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/forvo.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/fptai.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/google.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/keys.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/libretranslate.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/mandarincantonese.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/options.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/pythainlp.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/service.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/servicemanager.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/spacy.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/test_services.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/tokenization.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/translationlanguage.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/transliterationlanguage.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/ttsvoice.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/vocalware.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/voicen.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/watson.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/wenlin.py +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/SOURCES.txt +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/dependency_links.txt +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/top_level.txt +0 -0
- {cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cloudlanguagetools
|
3
|
-
Version:
|
3
|
+
Version: 7.0
|
4
4
|
Summary: Interface with various cloud APIs for language processing such as translation, text to speech
|
5
5
|
Home-page: https://github.com/Language-Tools/cloud-language-tools-core
|
6
6
|
Author: Luc
|
@@ -99,6 +99,12 @@ class ElevenLabsService(cloudlanguagetools.service.Service):
|
|
99
99
|
}
|
100
100
|
|
101
101
|
response = requests.post(url, json=data, headers=headers, timeout=cloudlanguagetools.constants.RequestTimeout)
|
102
|
+
if response.status_code != 200:
|
103
|
+
error_message = f'ElevenLabs: error processing TTS request: {response.status_code} {response.text}'
|
104
|
+
logger.error(error_message)
|
105
|
+
raise cloudlanguagetools.errors.RequestError(error_message)
|
106
|
+
|
107
|
+
|
102
108
|
response.raise_for_status()
|
103
109
|
|
104
110
|
output_temp_file = tempfile.NamedTemporaryFile()
|
@@ -144,6 +150,11 @@ class ElevenLabsService(cloudlanguagetools.service.Service):
|
|
144
150
|
response = requests.get(url, headers=self.get_headers(), timeout=cloudlanguagetools.constants.RequestTimeout)
|
145
151
|
response.raise_for_status()
|
146
152
|
model_data = response.json()
|
153
|
+
|
154
|
+
# restrict to models that can do text to speech (elevenlabs introduced voice conversion)
|
155
|
+
model_data = [model for model in model_data if model['can_do_text_to_speech']]
|
156
|
+
|
157
|
+
#pprint.pprint(model_data)
|
147
158
|
# model_data:
|
148
159
|
# [{'can_be_finetuned': True,
|
149
160
|
# 'can_do_text_to_speech': True,
|
@@ -185,7 +196,7 @@ class ElevenLabsService(cloudlanguagetools.service.Service):
|
|
185
196
|
for model in model_data:
|
186
197
|
model_id = model['model_id']
|
187
198
|
model_name = model['name']
|
188
|
-
model_short_name = model_name.replace('Eleven ', '').
|
199
|
+
model_short_name = model_name.replace('Eleven ', '').strip()
|
189
200
|
for language_record in model['languages']:
|
190
201
|
try:
|
191
202
|
language_id = language_record['language_id']
|
@@ -256,14 +256,15 @@ class AudioLanguage(enum.Enum):
|
|
256
256
|
az_AZ = (Language.az, "Azerbaijani (Azerbaijan)")
|
257
257
|
ba_RU = (Language.ba, "Bashkir (Russia)")
|
258
258
|
|
259
|
-
|
259
|
+
be_BY = (Language.be, "Belarusian (Belarus)")
|
260
|
+
bg_BG = (Language.bg, "Bulgarian (Bulgaria)")
|
260
261
|
bn_BD = (Language.bn, "Bangla (Bangladesh)")
|
261
262
|
bn_IN = (Language.bn, "Bengali (India)")
|
262
263
|
bs_BA = (Language.bs, "Bosnian (Bosnia and Herzegovina)")
|
263
264
|
ca_ES = (Language.ca, "Catalan")
|
264
265
|
cs_CZ = (Language.cs, "Czech")
|
265
266
|
cy_GB = (Language.cy, "Welsh")
|
266
|
-
da_DK = (Language.da, "Danish")
|
267
|
+
da_DK = (Language.da, "Danish (Denmark)")
|
267
268
|
fo_FO = (Language.fo, "Faroese (Faroe Islands)")
|
268
269
|
de_AT = (Language.de, "German (Austria)")
|
269
270
|
de_CH = (Language.de, "German (Switzerland)")
|
@@ -311,7 +312,7 @@ class AudioLanguage(enum.Enum):
|
|
311
312
|
es_UY = (Language.es, "Spanish (Uruguay)")
|
312
313
|
es_VE = (Language.es, "Spanish (Venezuela)")
|
313
314
|
|
314
|
-
et_EE = (Language.et, "Estonian")
|
315
|
+
et_EE = (Language.et, "Estonian (Estonia)")
|
315
316
|
eu_ES = (Language.eu, "Basque (Basque Country)")
|
316
317
|
fi_FI = (Language.fi, "Finnish")
|
317
318
|
fil_PH = (Language.tl, "Filipino (Philippines)")
|
@@ -349,10 +350,10 @@ class AudioLanguage(enum.Enum):
|
|
349
350
|
ms_MY = (Language.ms, "Malay")
|
350
351
|
mt_MT = (Language.mt, "Maltese (Malta)")
|
351
352
|
my_MM = (Language.my, "Burmese (Myanmar [Burma])")
|
352
|
-
nb_NO = (Language.nb, "Norwegian")
|
353
|
+
nb_NO = (Language.nb, "Norwegian (Norway)")
|
353
354
|
ne_NP = (Language.ne, "Nepali (Nepal)")
|
354
355
|
nl_BE = (Language.nl, "Dutch (Belgium)")
|
355
|
-
nl_NL = (Language.nl, "Dutch")
|
356
|
+
nl_NL = (Language.nl, "Dutch (Netherlands)")
|
356
357
|
pa_IN = (Language.pa, "Punjabi (India)")
|
357
358
|
pl_PL = (Language.pl, "Polish")
|
358
359
|
ps_AF = (Language.ps, "Pashto (Afghanistan)")
|
@@ -126,7 +126,7 @@ class NaverService(cloudlanguagetools.service.Service):
|
|
126
126
|
return [
|
127
127
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.en_US, 'clara', cloudlanguagetools.constants.Gender.Female, 'Clara', 'General'),
|
128
128
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.en_US, 'danna', cloudlanguagetools.constants.Gender.Female, 'Anna', 'Premium'),
|
129
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.en_US, 'djoey', cloudlanguagetools.constants.Gender.Female, '
|
129
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.en_US, 'djoey', cloudlanguagetools.constants.Gender.Female, 'Joey', 'General'),
|
130
130
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.en_US, 'matt', cloudlanguagetools.constants.Gender.Male, 'Matt', 'General'),
|
131
131
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.es_ES, 'carmen', cloudlanguagetools.constants.Gender.Female, 'Carmen', 'General'),
|
132
132
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.es_ES, 'jose', cloudlanguagetools.constants.Gender.Male, 'Jose', 'General'),
|
@@ -135,15 +135,18 @@ class NaverService(cloudlanguagetools.service.Service):
|
|
135
135
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'deriko', cloudlanguagetools.constants.Gender.Female, 'Eriko', 'Premium'),
|
136
136
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dhajime', cloudlanguagetools.constants.Gender.Male, 'Hajime', 'Premium'),
|
137
137
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dmio', cloudlanguagetools.constants.Gender.Female, 'Mio', 'Premium'),
|
138
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dnaomi', cloudlanguagetools.constants.Gender.Female, 'Naomi', 'Premium'),
|
138
139
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dnaomi_formal', cloudlanguagetools.constants.Gender.Female, 'Naomi (news)', 'Premium'),
|
139
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dnaomi_joyful', cloudlanguagetools.constants.Gender.Female, 'Naomi (
|
140
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dnaomi_joyful', cloudlanguagetools.constants.Gender.Female, 'Naomi (joyful)', 'Premium'),
|
140
141
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'driko', cloudlanguagetools.constants.Gender.Female, 'Riko', 'Premium'),
|
142
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dsayuri', cloudlanguagetools.constants.Gender.Female, 'Sayuri', 'Premium'),
|
143
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'dtomoko', cloudlanguagetools.constants.Gender.Female, 'Tomoko', 'Premium'),
|
141
144
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'nnaomi', cloudlanguagetools.constants.Gender.Female, 'Naomi', 'Premium'),
|
142
145
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'nsayuri', cloudlanguagetools.constants.Gender.Female, 'Sayuri', 'Premium'),
|
143
146
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'ntomoko', cloudlanguagetools.constants.Gender.Female, 'Tomoko', 'Premium'),
|
144
147
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ja_JP, 'shinji', cloudlanguagetools.constants.Gender.Male, 'Shinji', 'General'),
|
145
148
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'dara_ang', cloudlanguagetools.constants.Gender.Female, 'Ara (angry)', 'Premium'),
|
146
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'dara-danna', cloudlanguagetools.constants.Gender.Female, 'Ara&Anna', 'Premium'),
|
149
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'dara-danna', cloudlanguagetools.constants.Gender.Female, 'Ara & Anna', 'Premium'),
|
147
150
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'dsinu-matt', cloudlanguagetools.constants.Gender.Male, 'Shinwoo & Matt', 'Premium'),
|
148
151
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'jinho', cloudlanguagetools.constants.Gender.Male, 'Jinho', 'General'),
|
149
152
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'mijin', cloudlanguagetools.constants.Gender.Female, 'Mijin', 'General'),
|
@@ -151,66 +154,85 @@ class NaverService(cloudlanguagetools.service.Service):
|
|
151
154
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nara_call', cloudlanguagetools.constants.Gender.Female, 'Ara (agent)', 'Premium'),
|
152
155
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nara', cloudlanguagetools.constants.Gender.Female, 'Ara', 'Premium'),
|
153
156
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nbora', cloudlanguagetools.constants.Gender.Female, 'Bora', 'Premium'),
|
157
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ndaeseong', cloudlanguagetools.constants.Gender.Male, 'Daeseong', 'Premium'),
|
154
158
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ndain', cloudlanguagetools.constants.Gender.Female, 'Dain', 'Premium (Child)'),
|
159
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ndonghyun', cloudlanguagetools.constants.Gender.Male, 'Donghyun', 'Premium'),
|
155
160
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nes_c_hyeri', cloudlanguagetools.constants.Gender.Female, 'Hyeri', 'Premium'),
|
156
161
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nes_c_kihyo', cloudlanguagetools.constants.Gender.Male, 'Kihyo', 'Premium'),
|
157
162
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nes_c_mikyung', cloudlanguagetools.constants.Gender.Female, 'Mikyung', 'Premium'),
|
158
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nes_c_sohyun', cloudlanguagetools.constants.Gender.Female, '
|
163
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nes_c_sohyun', cloudlanguagetools.constants.Gender.Female, 'Sohyun', 'Premium'),
|
159
164
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'neunseo', cloudlanguagetools.constants.Gender.Female, 'Eunseo', 'Premium'),
|
160
165
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'neunwoo', cloudlanguagetools.constants.Gender.Male, 'Eunwoo', 'Premium'),
|
161
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'neunyoung', cloudlanguagetools.constants.Gender.Female, 'Eunyoung
|
166
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'neunyoung', cloudlanguagetools.constants.Gender.Female, 'Eunyoung', 'Premium'),
|
162
167
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ngaram', cloudlanguagetools.constants.Gender.Female, 'Garam', 'Premium (Child)'),
|
163
168
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ngoeun', cloudlanguagetools.constants.Gender.Female, 'Goeun', 'Premium'),
|
169
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ngyeongjun', cloudlanguagetools.constants.Gender.Male, 'Gyeongjun', 'Premium'),
|
164
170
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nhajun', cloudlanguagetools.constants.Gender.Male, 'Hajun', 'Premium (Child)'),
|
165
171
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nheera', cloudlanguagetools.constants.Gender.Female, 'Heera', 'Premium'),
|
166
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
172
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nian', cloudlanguagetools.constants.Gender.Male, 'Ian', 'Premium'),
|
173
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nihyun', cloudlanguagetools.constants.Gender.Female, 'Leehyeon', 'Premium'),
|
167
174
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njaewook', cloudlanguagetools.constants.Gender.Male, 'Jaewook', 'Premium'),
|
168
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njangj', cloudlanguagetools.constants.Gender.Female, '
|
175
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njangj', cloudlanguagetools.constants.Gender.Female, 'Deurim', 'Premium'),
|
169
176
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njihun', cloudlanguagetools.constants.Gender.Male, 'Jihun', 'Premium'),
|
170
177
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njihwan', cloudlanguagetools.constants.Gender.Male, 'Jihwan', 'Premium'),
|
171
178
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njinho', cloudlanguagetools.constants.Gender.Male, 'Jinho', 'Premium'),
|
172
179
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njiwon', cloudlanguagetools.constants.Gender.Female, 'Jiwon', 'Premium'),
|
173
180
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njiyun', cloudlanguagetools.constants.Gender.Female, 'Jiyun', 'Premium'),
|
181
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njonghyeok', cloudlanguagetools.constants.Gender.Male, 'Jonghyeok', 'Premium'),
|
174
182
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njonghyun', cloudlanguagetools.constants.Gender.Male, 'Jonghyun', 'Premium'),
|
175
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njooahn', cloudlanguagetools.constants.Gender.Male, '
|
176
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njoonyoung', cloudlanguagetools.constants.Gender.Male, '
|
183
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njooahn', cloudlanguagetools.constants.Gender.Male, 'Jooahn', 'Premium'),
|
184
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'njoonyoung', cloudlanguagetools.constants.Gender.Male, 'Joonyoung', 'Premium'),
|
177
185
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkitae', cloudlanguagetools.constants.Gender.Male, 'Kitae', 'Premium'),
|
178
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyunglee', cloudlanguagetools.constants.Gender.Female, '
|
179
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyungtae', cloudlanguagetools.constants.Gender.Male, '
|
180
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyuwon', cloudlanguagetools.constants.Gender.Male, '
|
186
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyunglee', cloudlanguagetools.constants.Gender.Female, 'Kyunglee', 'Premium'),
|
187
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyungtae', cloudlanguagetools.constants.Gender.Male, 'Kyungtae', 'Premium'),
|
188
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nkyuwon', cloudlanguagetools.constants.Gender.Male, 'Kyuwon', 'Premium'),
|
189
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nmammon', cloudlanguagetools.constants.Gender.Male, 'Demon Mammon', 'Premium'),
|
190
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nmeow', cloudlanguagetools.constants.Gender.Female, 'Kitty', 'Premium (Child)'),
|
181
191
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nminjeong', cloudlanguagetools.constants.Gender.Female, 'Minjeong', 'Premium'),
|
182
192
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nminsang', cloudlanguagetools.constants.Gender.Male, 'Minsang', 'Premium'),
|
183
193
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nminseo', cloudlanguagetools.constants.Gender.Female, 'Minseo', 'Premium'),
|
184
194
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nminyoung', cloudlanguagetools.constants.Gender.Female, 'Minyoung', 'Premium'),
|
195
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nmovie', cloudlanguagetools.constants.Gender.Male, 'Choi Moobi', 'Premium'),
|
185
196
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nnarae', cloudlanguagetools.constants.Gender.Female, 'Narae', 'Premium'),
|
186
197
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'noyj', cloudlanguagetools.constants.Gender.Female, 'Bomdal', 'Premium'),
|
187
198
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nraewon', cloudlanguagetools.constants.Gender.Male, 'Raewon', 'Premium'),
|
188
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
199
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nreview', cloudlanguagetools.constants.Gender.Male, 'Park Leebyu', 'Premium'),
|
200
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsabina', cloudlanguagetools.constants.Gender.Female, 'Witch Sabina', 'Premium'),
|
201
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsangdo', cloudlanguagetools.constants.Gender.Male, 'Sangdo', 'Premium'),
|
202
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nseonghoon', cloudlanguagetools.constants.Gender.Male, 'Seonghoon', 'Premium'),
|
189
203
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nseungpyo', cloudlanguagetools.constants.Gender.Male, 'Seungpyo', 'Premium'),
|
190
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
204
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nshasha', cloudlanguagetools.constants.Gender.Female, 'Shasha', 'Premium'),
|
205
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsinu', cloudlanguagetools.constants.Gender.Male, 'Sinwoo', 'Premium'),
|
191
206
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsiyoon', cloudlanguagetools.constants.Gender.Male, 'Siyoon', 'Premium'),
|
192
207
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsujin', cloudlanguagetools.constants.Gender.Female, 'Sujin', 'Premium'),
|
193
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsunhee', cloudlanguagetools.constants.Gender.Female, '
|
194
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsunkyung', cloudlanguagetools.constants.Gender.Female, '
|
208
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsunhee', cloudlanguagetools.constants.Gender.Female, 'Sunhee', 'Premium'),
|
209
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nsunkyung', cloudlanguagetools.constants.Gender.Female, 'Sunkyung', 'Premium'),
|
195
210
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ntaejin', cloudlanguagetools.constants.Gender.Male, 'Taejin', 'Premium'),
|
196
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ntiffany', cloudlanguagetools.constants.Gender.Female, '
|
211
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'ntiffany', cloudlanguagetools.constants.Gender.Female, 'Kiseo', 'Premium'),
|
197
212
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nwontak', cloudlanguagetools.constants.Gender.Male, 'Wontak', 'Premium'),
|
213
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nwoof', cloudlanguagetools.constants.Gender.Male, 'Doggy', 'Premium (Child)'),
|
198
214
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nwoosik', cloudlanguagetools.constants.Gender.Male, 'Woosik', 'Premium'),
|
199
215
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyeji', cloudlanguagetools.constants.Gender.Female, 'Yeji', 'Premium'),
|
200
216
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyejin', cloudlanguagetools.constants.Gender.Female, 'Yejin', 'Premium'),
|
217
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyounghwa', cloudlanguagetools.constants.Gender.Female, 'Jung Younghwa', 'Premium'),
|
201
218
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyoungil', cloudlanguagetools.constants.Gender.Male, 'Youngil', 'Premium'),
|
202
219
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyoungmi', cloudlanguagetools.constants.Gender.Female, 'Youngmi', 'Premium'),
|
203
220
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyujin', cloudlanguagetools.constants.Gender.Female, 'Yujin', 'Premium'),
|
204
221
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'nyuna', cloudlanguagetools.constants.Gender.Female, 'Yuna', 'Premium'),
|
205
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vara', cloudlanguagetools.constants.Gender.Female, 'Ara', 'Premium'),
|
206
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
207
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
208
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
209
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, '
|
222
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vara', cloudlanguagetools.constants.Gender.Female, 'Ara (pro)', 'Premium'),
|
223
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vdaeseong', cloudlanguagetools.constants.Gender.Male, 'Daeseong (pro)', 'Premium'),
|
224
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vdain', cloudlanguagetools.constants.Gender.Female, 'Dain (pro)', 'Premium'),
|
225
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vdonghyun', cloudlanguagetools.constants.Gender.Male, 'Donghyun (pro)', 'Premium'),
|
226
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vgoeun', cloudlanguagetools.constants.Gender.Female, 'Goeun (pro)', 'Premium'),
|
227
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vhyeri', cloudlanguagetools.constants.Gender.Female, 'Hyeri (pro)', 'Premium'),
|
228
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vian', cloudlanguagetools.constants.Gender.Male, 'Ian (pro)', 'Premium'),
|
229
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vmikyung', cloudlanguagetools.constants.Gender.Female, 'Mikyung (pro)', 'Premium'),
|
230
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.ko_KR, 'vyuna', cloudlanguagetools.constants.Gender.Female, 'Yuna (pro)', 'Premium'),
|
210
231
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_CN, 'liangliang', cloudlanguagetools.constants.Gender.Male, 'Liangliang', 'General'),
|
211
232
|
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_CN, 'meimei', cloudlanguagetools.constants.Gender.Female, 'Meimei', 'General'),
|
212
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_TW, 'chiahua', cloudlanguagetools.constants.Gender.Female, '
|
213
|
-
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_TW, 'kuanlin', cloudlanguagetools.constants.Gender.Male, '
|
233
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_TW, 'chiahua', cloudlanguagetools.constants.Gender.Female, 'Chiahua', 'Premium'),
|
234
|
+
NaverVoice(cloudlanguagetools.languages.AudioLanguage.zh_TW, 'kuanlin', cloudlanguagetools.constants.Gender.Male, 'Kuanlin', 'Premium'),
|
235
|
+
|
214
236
|
|
215
237
|
|
216
238
|
|
@@ -0,0 +1,206 @@
|
|
1
|
+
from openai import OpenAI
|
2
|
+
|
3
|
+
import logging
|
4
|
+
import tempfile
|
5
|
+
import pydub
|
6
|
+
import pprint
|
7
|
+
from typing import List
|
8
|
+
|
9
|
+
import cloudlanguagetools.service
|
10
|
+
import cloudlanguagetools.constants
|
11
|
+
import cloudlanguagetools.languages
|
12
|
+
import cloudlanguagetools.options
|
13
|
+
|
14
|
+
from cloudlanguagetools.languages import AudioLanguage
|
15
|
+
|
16
|
+
logger = logging.getLogger(__name__)
|
17
|
+
|
18
|
+
DEFAULT_TTS_SPEED = 1.0
|
19
|
+
|
20
|
+
class OpenAIVoice(cloudlanguagetools.ttsvoice.TtsVoice):
|
21
|
+
def __init__(self, name: str,
|
22
|
+
audio_language: cloudlanguagetools.languages.AudioLanguage,
|
23
|
+
gender: cloudlanguagetools.constants.Gender):
|
24
|
+
self.name = name
|
25
|
+
self.gender = gender
|
26
|
+
self.audio_language = audio_language
|
27
|
+
self.service = cloudlanguagetools.constants.Service.OpenAI
|
28
|
+
self.service_fee = cloudlanguagetools.constants.ServiceFee.paid
|
29
|
+
|
30
|
+
def get_voice_key(self):
|
31
|
+
return {
|
32
|
+
'name': self.name,
|
33
|
+
'language': self.audio_language.name
|
34
|
+
}
|
35
|
+
|
36
|
+
def get_voice_shortname(self):
|
37
|
+
return self.name
|
38
|
+
|
39
|
+
def get_options(self):
|
40
|
+
return {
|
41
|
+
'speed' : {
|
42
|
+
'type': cloudlanguagetools.options.ParameterType.number.name,
|
43
|
+
'min': 0.25,
|
44
|
+
'max': 4.0,
|
45
|
+
'default': DEFAULT_TTS_SPEED
|
46
|
+
},
|
47
|
+
cloudlanguagetools.options.AUDIO_FORMAT_PARAMETER: {
|
48
|
+
'type': cloudlanguagetools.options.ParameterType.list.name,
|
49
|
+
'values': [
|
50
|
+
cloudlanguagetools.options.AudioFormat.mp3.name,
|
51
|
+
cloudlanguagetools.options.AudioFormat.ogg_opus.name,
|
52
|
+
],
|
53
|
+
'default': cloudlanguagetools.options.AudioFormat.mp3.name
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
class OpenAIService(cloudlanguagetools.service.Service):
|
58
|
+
def __init__(self):
|
59
|
+
self.chatbot_model = "gpt-3.5-turbo"
|
60
|
+
|
61
|
+
def configure(self, config):
|
62
|
+
self.api_key = config['api_key']
|
63
|
+
self.client = OpenAI(api_key=self.api_key)
|
64
|
+
|
65
|
+
def single_prompt(self, prompt, max_tokens):
|
66
|
+
messages = [
|
67
|
+
{'role': 'user', 'content': prompt}
|
68
|
+
]
|
69
|
+
|
70
|
+
if max_tokens != None:
|
71
|
+
response = self.client.chat.completions.create(model=self.chatbot_model,
|
72
|
+
messages=messages,
|
73
|
+
max_tokens=max_tokens)
|
74
|
+
else:
|
75
|
+
response = self.client.chat.completions.create(model=self.chatbot_model,
|
76
|
+
messages=messages)
|
77
|
+
logger.debug(pprint.pformat(response))
|
78
|
+
tokens_used = response.usage.total_tokens
|
79
|
+
response_text = response.choices[0].message.content
|
80
|
+
return response_text, tokens_used
|
81
|
+
|
82
|
+
def full_query(self, messages, max_tokens):
|
83
|
+
if max_tokens != None:
|
84
|
+
response = self.client.chat.completions.create(model=self.chatbot_model,
|
85
|
+
messages=messages,
|
86
|
+
max_tokens=max_tokens)
|
87
|
+
else:
|
88
|
+
response = self.client.chat.completions.create(model=self.chatbot_model,
|
89
|
+
messages=messages)
|
90
|
+
logger.debug(pprint.pformat(response))
|
91
|
+
return response
|
92
|
+
|
93
|
+
def speech_to_text(self, filepath, audio_format: cloudlanguagetools.options.AudioFormat):
|
94
|
+
|
95
|
+
if audio_format in [cloudlanguagetools.options.AudioFormat.ogg_opus, cloudlanguagetools.options.AudioFormat.ogg_vorbis]:
|
96
|
+
# need to convert to wav first
|
97
|
+
sound = pydub.AudioSegment.from_ogg(filepath)
|
98
|
+
wav_tempfile = tempfile.NamedTemporaryFile(prefix='cloudlanguagetools_OpenAI_speech_to_text', suffix='.wav')
|
99
|
+
sound.export(wav_tempfile.name, format="wav")
|
100
|
+
filepath = wav_tempfile.name
|
101
|
+
|
102
|
+
logger.debug(f'opening file {filepath}')
|
103
|
+
audio_file= open(filepath, "rb")
|
104
|
+
transcript = self.client.audio.transcriptions.create(model="whisper-1", file=audio_file)
|
105
|
+
return transcript.text
|
106
|
+
|
107
|
+
|
108
|
+
def get_tts_voice_list(self) -> List[OpenAIVoice]:
|
109
|
+
result = []
|
110
|
+
|
111
|
+
supported_languages = [
|
112
|
+
AudioLanguage.af_ZA,
|
113
|
+
AudioLanguage.ar_XA,
|
114
|
+
AudioLanguage.hy_AM,
|
115
|
+
AudioLanguage.az_AZ,
|
116
|
+
AudioLanguage.be_BY,
|
117
|
+
AudioLanguage.bs_BA,
|
118
|
+
AudioLanguage.bg_BG,
|
119
|
+
AudioLanguage.ca_ES,
|
120
|
+
AudioLanguage.zh_CN,
|
121
|
+
AudioLanguage.hr_HR,
|
122
|
+
AudioLanguage.cs_CZ,
|
123
|
+
AudioLanguage.da_DK,
|
124
|
+
AudioLanguage.nl_NL,
|
125
|
+
AudioLanguage.en_US,
|
126
|
+
AudioLanguage.et_EE,
|
127
|
+
AudioLanguage.fi_FI,
|
128
|
+
AudioLanguage.fr_FR,
|
129
|
+
AudioLanguage.gl_ES,
|
130
|
+
AudioLanguage.de_DE,
|
131
|
+
AudioLanguage.el_GR,
|
132
|
+
AudioLanguage.he_IL,
|
133
|
+
AudioLanguage.hi_IN,
|
134
|
+
AudioLanguage.hu_HU,
|
135
|
+
AudioLanguage.is_IS,
|
136
|
+
AudioLanguage.id_ID,
|
137
|
+
AudioLanguage.it_IT,
|
138
|
+
AudioLanguage.ja_JP,
|
139
|
+
AudioLanguage.kn_IN,
|
140
|
+
AudioLanguage.kk_KZ,
|
141
|
+
AudioLanguage.ko_KR,
|
142
|
+
AudioLanguage.lv_LV,
|
143
|
+
AudioLanguage.lt_LT,
|
144
|
+
AudioLanguage.mk_MK,
|
145
|
+
AudioLanguage.ms_MY,
|
146
|
+
AudioLanguage.mr_IN,
|
147
|
+
AudioLanguage.ne_NP,
|
148
|
+
AudioLanguage.nb_NO,
|
149
|
+
AudioLanguage.fa_IR,
|
150
|
+
AudioLanguage.pl_PL,
|
151
|
+
AudioLanguage.pt_PT,
|
152
|
+
AudioLanguage.pt_BR,
|
153
|
+
AudioLanguage.ro_RO,
|
154
|
+
AudioLanguage.ru_RU,
|
155
|
+
AudioLanguage.sr_RS,
|
156
|
+
AudioLanguage.sk_SK,
|
157
|
+
AudioLanguage.sl_SI,
|
158
|
+
AudioLanguage.es_ES,
|
159
|
+
AudioLanguage.es_MX,
|
160
|
+
AudioLanguage.sw_KE,
|
161
|
+
AudioLanguage.sv_SE,
|
162
|
+
# AudioLanguage.tl_PH, # need to add tagalog language in AudioLanguages
|
163
|
+
AudioLanguage.ta_IN,
|
164
|
+
AudioLanguage.ta_LK,
|
165
|
+
AudioLanguage.th_TH,
|
166
|
+
AudioLanguage.tr_TR,
|
167
|
+
AudioLanguage.uk_UA,
|
168
|
+
AudioLanguage.ur_PK,
|
169
|
+
AudioLanguage.ur_IN,
|
170
|
+
AudioLanguage.vi_VN,
|
171
|
+
AudioLanguage.cy_GB
|
172
|
+
]
|
173
|
+
|
174
|
+
for audio_language in supported_languages:
|
175
|
+
result.extend([
|
176
|
+
OpenAIVoice('alloy', audio_language, cloudlanguagetools.constants.Gender.Female),
|
177
|
+
OpenAIVoice('echo', audio_language, cloudlanguagetools.constants.Gender.Male),
|
178
|
+
OpenAIVoice('fable', audio_language, cloudlanguagetools.constants.Gender.Female),
|
179
|
+
OpenAIVoice('onyx', audio_language, cloudlanguagetools.constants.Gender.Male),
|
180
|
+
OpenAIVoice('nova', audio_language, cloudlanguagetools.constants.Gender.Female),
|
181
|
+
OpenAIVoice('shimmer', audio_language, cloudlanguagetools.constants.Gender.Female),
|
182
|
+
])
|
183
|
+
return result
|
184
|
+
|
185
|
+
def get_tts_audio(self, text, voice_key, options):
|
186
|
+
# https://platform.openai.com/docs/guides/text-to-speech
|
187
|
+
# https://platform.openai.com/docs/api-reference/audio/createSpeech?lang=python
|
188
|
+
|
189
|
+
output_temp_file = tempfile.NamedTemporaryFile()
|
190
|
+
|
191
|
+
speed = options.get('speed', DEFAULT_TTS_SPEED)
|
192
|
+
response_format = options.get(cloudlanguagetools.options.AUDIO_FORMAT_PARAMETER,
|
193
|
+
cloudlanguagetools.options.AudioFormat.mp3.name)
|
194
|
+
if response_format == cloudlanguagetools.options.AudioFormat.ogg_opus.name:
|
195
|
+
response_format = 'opus'
|
196
|
+
|
197
|
+
response = self.client.audio.speech.create(
|
198
|
+
model='tts-1-hd',
|
199
|
+
voice=voice_key['name'],
|
200
|
+
input=text,
|
201
|
+
response_format=response_format,
|
202
|
+
speed=speed
|
203
|
+
)
|
204
|
+
response.stream_to_file(output_temp_file.name)
|
205
|
+
|
206
|
+
return output_temp_file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cloudlanguagetools
|
3
|
-
Version:
|
3
|
+
Version: 7.0
|
4
4
|
Summary: Interface with various cloud APIs for language processing such as translation, text to speech
|
5
5
|
Home-page: https://github.com/Language-Tools/cloud-language-tools-core
|
6
6
|
Author: Luc
|
@@ -6,7 +6,7 @@ from setuptools.command.install import install
|
|
6
6
|
# twine upload dist/*
|
7
7
|
|
8
8
|
setup(name='cloudlanguagetools',
|
9
|
-
version='
|
9
|
+
version='7.0',
|
10
10
|
description='Interface with various cloud APIs for language processing such as translation, text to speech',
|
11
11
|
long_description=open('README.rst', encoding='utf-8').read(),
|
12
12
|
url='https://github.com/Language-Tools/cloud-language-tools-core',
|
@@ -21,7 +21,7 @@ setup(name='cloudlanguagetools',
|
|
21
21
|
packages=['cloudlanguagetools'],
|
22
22
|
install_requires=[
|
23
23
|
'clt_wenlin>=1.0',
|
24
|
-
'clt_requirements>=1.
|
24
|
+
'clt_requirements>=1.1',
|
25
25
|
'pinyin_jyutping>=0.9',
|
26
26
|
],
|
27
27
|
)
|
@@ -1,72 +0,0 @@
|
|
1
|
-
import openai
|
2
|
-
import pprint
|
3
|
-
import logging
|
4
|
-
import tempfile
|
5
|
-
import pydub
|
6
|
-
|
7
|
-
import cloudlanguagetools.service
|
8
|
-
import cloudlanguagetools.constants
|
9
|
-
import cloudlanguagetools.languages
|
10
|
-
import cloudlanguagetools.options
|
11
|
-
import cloudlanguagetools.transliterationlanguage
|
12
|
-
|
13
|
-
logger = logging.getLogger(__name__)
|
14
|
-
|
15
|
-
class OpenAIService(cloudlanguagetools.service.Service):
|
16
|
-
def __init__(self):
|
17
|
-
self.chatbot_model = "gpt-3.5-turbo"
|
18
|
-
|
19
|
-
def configure(self, config):
|
20
|
-
self.api_key = config['api_key']
|
21
|
-
openai.api_key = self.api_key
|
22
|
-
|
23
|
-
def single_prompt(self, prompt, max_tokens):
|
24
|
-
messages = [
|
25
|
-
{'role': 'user', 'content': prompt}
|
26
|
-
]
|
27
|
-
|
28
|
-
if max_tokens != None:
|
29
|
-
response = openai.ChatCompletion.create(
|
30
|
-
model=self.chatbot_model,
|
31
|
-
messages=messages,
|
32
|
-
max_tokens=max_tokens
|
33
|
-
)
|
34
|
-
else:
|
35
|
-
response = openai.ChatCompletion.create(
|
36
|
-
model=self.chatbot_model,
|
37
|
-
messages=messages
|
38
|
-
)
|
39
|
-
logger.debug(pprint.pformat(response))
|
40
|
-
tokens_used = response['usage']['total_tokens']
|
41
|
-
response_text = response['choices'][0]['message']['content']
|
42
|
-
return response_text, tokens_used
|
43
|
-
|
44
|
-
def full_query(self, messages, max_tokens):
|
45
|
-
if max_tokens != None:
|
46
|
-
response = openai.ChatCompletion.create(
|
47
|
-
model=self.chatbot_model,
|
48
|
-
messages=messages,
|
49
|
-
max_tokens=max_tokens
|
50
|
-
)
|
51
|
-
else:
|
52
|
-
response = openai.ChatCompletion.create(
|
53
|
-
model=self.chatbot_model,
|
54
|
-
messages=messages
|
55
|
-
)
|
56
|
-
logger.debug(pprint.pformat(response))
|
57
|
-
return response
|
58
|
-
|
59
|
-
def speech_to_text(self, filepath, audio_format: cloudlanguagetools.options.AudioFormat):
|
60
|
-
|
61
|
-
if audio_format in [cloudlanguagetools.options.AudioFormat.ogg_opus, cloudlanguagetools.options.AudioFormat.ogg_vorbis]:
|
62
|
-
# need to convert to wav first
|
63
|
-
sound = pydub.AudioSegment.from_ogg(filepath)
|
64
|
-
wav_tempfile = tempfile.NamedTemporaryFile(prefix='cloudlanguagetools_OpenAI_speech_to_text', suffix='.wav')
|
65
|
-
sound.export(wav_tempfile.name, format="wav")
|
66
|
-
filepath = wav_tempfile.name
|
67
|
-
|
68
|
-
logger.debug(f'opening file {filepath}')
|
69
|
-
audio_file= open(filepath, "rb")
|
70
|
-
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
71
|
-
return transcript['text']
|
72
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools/transliterationlanguage.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cloudlanguagetools-6.8 → cloudlanguagetools-7.0}/cloudlanguagetools.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|