clr commited on
Commit
e1ec707
·
verified ·
1 Parent(s): 903733a

replace tiro tts service with grammatek

Browse files
Files changed (1) hide show
  1. scripts/tapi.py +36 -0
scripts/tapi.py CHANGED
@@ -11,6 +11,7 @@ def tiro(text,voice,save='./',tiroalign = False):
11
  # endpoint working 2023
12
  url = 'https://tts.tiro.is/v0/speech'
13
  headers = {'Content-Type': 'application/json'}
 
14
 
15
 
16
  # synthesis
@@ -60,4 +61,39 @@ def tiro(text,voice,save='./',tiroalign = False):
60
  return os.path.abspath(wname)
61
 
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
 
11
  # endpoint working 2023
12
  url = 'https://tts.tiro.is/v0/speech'
13
  headers = {'Content-Type': 'application/json'}
14
+ # NOT working as of 07.2025
15
 
16
 
17
  # synthesis
 
61
  return os.path.abspath(wname)
62
 
63
 
64
+ def grammatek(text,voice,save='./',UNUSED = False):
65
+
66
+ # endpoint working 2025
67
+ url = 'https://api.grammatek.com/tts/v0/speech'
68
+ headers = {'Content-Type': 'application/json',
69
+ 'Accept': 'audio/mpeg,audio/x-wav,audio/ogg'}
70
+
71
+
72
+ # synthesis
73
+ payload_tts = {
74
+ "Engine": "standard",
75
+ "LanguageCode": "is-IS",
76
+ "LexiconNames": [],
77
+ "OutputFormat": "pcm",
78
+ "SampleRate":"16000",
79
+ "SpeechMarkTypes": [
80
+ "word"
81
+ ],
82
+ "Text": text,
83
+ "TextType": "text",
84
+ "VoiceId": voice
85
+ }
86
+
87
+ wname = save+voice+'.wav'
88
+ tts_data = requests.post(url, headers=headers, json=payload_tts, verify=False)
89
+
90
+ with wave.open(wname,'wb') as f:
91
+ f.setnchannels(1)
92
+ f.setframerate(16000)
93
+ f.setsampwidth(2)
94
+ f.writeframes(tts_data.content)
95
+
96
+
97
+ #return(os.path.abspath(wname),os.path.abspath(aname))
98
+ return os.path.abspath(wname)
99