Mercurial Hosting > lang
comparison src/tts.mp3.luan @ 31:1e7d855afde3
voices
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 Aug 2025 17:05:38 -0600 |
parents | d3f5448743bf |
children |
comparison
equal
deleted
inserted
replaced
30:d48f48e1b790 | 31:1e7d855afde3 |
---|---|
16 ["Ocp-Apim-Subscription-Key"] = Config.azure_tts.key or error() | 16 ["Ocp-Apim-Subscription-Key"] = Config.azure_tts.key or error() |
17 ["Content-Type"] = "application/ssml+xml" | 17 ["Content-Type"] = "application/ssml+xml" |
18 ["X-Microsoft-OutputFormat"] = "audio-16khz-128kbitrate-mono-mp3" | 18 ["X-Microsoft-OutputFormat"] = "audio-16khz-128kbitrate-mono-mp3" |
19 } | 19 } |
20 | 20 |
21 local function text_to_speech(lang,text) | 21 local function text_to_speech(lang,voice,text) |
22 local xml = `%> | 22 local xml = `%> |
23 <speak version='1.0' xml:lang='<%=lang%>'> | 23 <speak version='1.0' xml:lang='<%=lang%>'> |
24 <voice name='en-US-BrandonMultilingualNeural'> | 24 <voice name='<%=voice%>'> |
25 <%= xml_encode(text) %> | 25 <%= xml_encode(text) %> |
26 </voice> | 26 </voice> |
27 </speak> | 27 </speak> |
28 <% ` | 28 <% ` |
29 local options = { | 29 local options = { |
34 return uri(url,options) | 34 return uri(url,options) |
35 end | 35 end |
36 | 36 |
37 return function() | 37 return function() |
38 local lang = Http.request.parameters.lang or error() | 38 local lang = Http.request.parameters.lang or error() |
39 local voice = Http.request.parameters.voice or error() | |
39 local text = Http.request.parameters.text or error() | 40 local text = Http.request.parameters.text or error() |
40 local input = text_to_speech(lang,text) | 41 local input = text_to_speech(lang,voice,text) |
41 Http.response.binary_writer().write_from(input) | 42 Http.response.binary_writer().write_from(input) |
42 end | 43 end |