Spaces:
Running
Running
Commit
•
31ac2a2
1
Parent(s):
bb473c7
MAX_CHAR
Browse files
.env
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
#change key to yours ,this is invalid
|
2 |
export SPEECH_KEY=299085b1a64047eb96f97d6c24ad91a5
|
3 |
export SPEECH_REGION=eastus
|
|
|
4 |
|
|
|
1 |
#change key to yours ,this is invalid
|
2 |
export SPEECH_KEY=299085b1a64047eb96f97d6c24ad91a5
|
3 |
export SPEECH_REGION=eastus
|
4 |
+
export MAX_CHAR=499
|
5 |
|
server.js
CHANGED
@@ -5,6 +5,9 @@ const sdk = require("microsoft-cognitiveservices-speech-sdk");
|
|
5 |
const path = require('path');
|
6 |
const fs = require('fs')
|
7 |
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
app.use(cors()); // Use cors middleware here
|
@@ -16,7 +19,13 @@ app.get('/tts/:text', async (req, res) => {
|
|
16 |
let startTime=Date.now();
|
17 |
console.log('start /tts ' + startTime);
|
18 |
let text = req?.params?.text || 'test';
|
19 |
-
let
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
try {
|
21 |
const response = await fetch("https://api.ttsopenai.com/api/v1/public/text-to-speech-stream", {
|
22 |
method: "POST",
|
|
|
5 |
const path = require('path');
|
6 |
const fs = require('fs')
|
7 |
|
8 |
+
let MAX_CHAR=parseInt(process.env.MAX_CHAR)
|
9 |
+
|
10 |
+
console.log('MAX_CHAR:',MAX_CHAR);
|
11 |
|
12 |
|
13 |
app.use(cors()); // Use cors middleware here
|
|
|
19 |
let startTime=Date.now();
|
20 |
console.log('start /tts ' + startTime);
|
21 |
let text = req?.params?.text || 'test';
|
22 |
+
let max_characters=MAX_CHAR || 498;
|
23 |
+
let subtext= text.substring(0, max_characters);
|
24 |
+
|
25 |
+
console.log('max_characters:',max_characters);
|
26 |
+
console.log('text that will be convert to audio:', subtext);
|
27 |
+
|
28 |
+
|
29 |
try {
|
30 |
const response = await fetch("https://api.ttsopenai.com/api/v1/public/text-to-speech-stream", {
|
31 |
method: "POST",
|