Skip to content

Commit c95a65b

Browse files
committed
revert back
1 parent 146298f commit c95a65b

File tree

3 files changed

+18
-71
lines changed

3 files changed

+18
-71
lines changed
Lines changed: 16 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,33 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
# import requests
5-
# from mycroft.tts import TTS, TTSValidator
6-
7-
# class botnoiTTSPlugin(TTS):
8-
# """Interface to Botnoi TTS."""
9-
# def __init__(self, lang, config):
10-
# super().__init__(lang, config, BotnoiTTSValidator(self))
11-
12-
# def get_tts(self, sentence, wav_file):
13-
# url = "https://openapi.botnoi.ai/service-api/text2speech-female?text=สวัสดี&speaker=tonkhaow"
14-
# headers = {
15-
# 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjYzMDgxMjYsImlkIjoiZjgxZDFlYmEtNTQ4Zi00ZjdiLWI1N2YtZDYxZjFhNGFlNmI3IiwiaXNzIjoiRVd0MGxYWHNzUVMzUklsMkVUVWczQnRYVEdHVkdFSlciLCJuYW1lIjoiS2VuIiwicGljIjoiaHR0cHM6Ly9wcm9maWxlLmxpbmUtc2Nkbi5uZXQvMGhMd0dtOElpUUUxaDZGRHdadUdCc0QwWlJIVFVOT2hVUUFub0lPRmhIU1d4ZWNWWUdUM05VYXcxSEhUOVFkd0VQUlNkWk9Bb1hTejFRIn0.jFbxULw3Mm9zY47n-QGVVQSsYUhy_T1Xqh_zoBrnHCY'
16-
# }
17-
# response = requests.request("GET", url, headers = headers)
18-
# with open(str('tts.wav'), 'wb') as file:
19-
# file.write(response.content)
20-
# return ('tts.wav', None) # No phonemes
21-
22-
# class BotnoiTTSValidator(TTSValidator):
23-
# def __init__(self, tts):
24-
# super(BotnoiTTSValidator, self).__init__(tts)
25-
26-
# def validate_lang(self):
27-
# pass
28-
29-
# def validate_connection(self):
30-
# pass
31-
32-
# def get_tts_class(self):
33-
# return botnoiTTSPlugin
34-
35-
36-
from gtts import gTTS
37-
from gtts.lang import tts_langs
38-
4+
import requests
395
from mycroft.tts import TTS, TTSValidator
406

41-
supported_langs = tts_langs()
42-
43-
447
class botnoiTTSPlugin(TTS):
45-
"""Interface to google TTS."""
8+
"""Interface to Botnoi TTS."""
469
def __init__(self, lang, config):
47-
if lang.lower() not in supported_langs and \
48-
lang[:2].lower() in supported_langs:
49-
lang = lang[:2]
50-
super(botnoiTTSPlugin, self).__init__(lang, config, GoogleTTSValidator(
51-
self), 'mp3')
10+
super().__init__(lang, config, BotnoiTTSValidator(self))
5211

5312
def get_tts(self, sentence, wav_file):
54-
"""Fetch tts audio using gTTS.
55-
Arguments:
56-
sentence (str): Sentence to generate audio for
57-
wav_file (str): output file path
58-
Returns:
59-
Tuple ((str) written file, None)
60-
"""
61-
tts = gTTS(text=sentence, lang=self.lang)
62-
tts.save(wav_file)
63-
return (wav_file, None) # No phonemes
64-
65-
66-
class GoogleTTSValidator(TTSValidator):
13+
url = "https://openapi.botnoi.ai/service-api/text2speech-female?text=สวัสดี&speaker=tonkhaow"
14+
headers = {
15+
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjYzMDgxMjYsImlkIjoiZjgxZDFlYmEtNTQ4Zi00ZjdiLWI1N2YtZDYxZjFhNGFlNmI3IiwiaXNzIjoiRVd0MGxYWHNzUVMzUklsMkVUVWczQnRYVEdHVkdFSlciLCJuYW1lIjoiS2VuIiwicGljIjoiaHR0cHM6Ly9wcm9maWxlLmxpbmUtc2Nkbi5uZXQvMGhMd0dtOElpUUUxaDZGRHdadUdCc0QwWlJIVFVOT2hVUUFub0lPRmhIU1d4ZWNWWUdUM05VYXcxSEhUOVFkd0VQUlNkWk9Bb1hTejFRIn0.jFbxULw3Mm9zY47n-QGVVQSsYUhy_T1Xqh_zoBrnHCY'
16+
}
17+
response = requests.request("GET", url, headers = headers)
18+
with open(str('tts.wav'), 'wb') as file:
19+
file.write(response.content)
20+
return ('tts.wav', None) # No phonemes
21+
22+
class BotnoiTTSValidator(TTSValidator):
6723
def __init__(self, tts):
68-
super(GoogleTTSValidator, self).__init__(tts)
24+
super(BotnoiTTSValidator, self).__init__(tts)
6925

7026
def validate_lang(self):
71-
lang = self.tts.lang
72-
if lang.lower() not in supported_langs:
73-
raise ValueError("Language not supported by gTTS: {}"
74-
.format(lang))
27+
pass
7528

7629
def validate_connection(self):
77-
try:
78-
gTTS(text='Hi').save(self.tts.filename)
79-
except Exception:
80-
raise Exception(
81-
'GoogleTTS server could not be verified. Please check your '
82-
'internet connection.')
30+
pass
8331

8432
def get_tts_class(self):
8533
return botnoiTTSPlugin

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# botnoi
2-
gTTS
1+
botnoi

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
author_email='natchpor@scg.com',
1717
license='Apache-2.0',
1818
packages=['mycroft_tts_plugin_botnoi'],
19-
install_requires=requirements,
19+
# install_requires=requirements,
2020
zip_safe=True,
2121
classifiers=[
2222
'Development Status :: 3 - Alpha',

0 commit comments

Comments
 (0)