plvictor commited on
Commit
a444030
·
verified ·
1 Parent(s): bf54584

Update textToSpeech/textToSpeech.js

Browse files
Files changed (1) hide show
  1. textToSpeech/textToSpeech.js +2 -22
textToSpeech/textToSpeech.js CHANGED
@@ -10,19 +10,14 @@ const MAX_CONCURRENT = Math.min(os.cpus().length, 4);
10
  let activeProcesses = 0;
11
  const requestQueue = [];
12
 
13
- // Cache de textos limpos para evitar reprocessamento
14
- const textCache = new Map();
15
 
16
  function cleanTextForTTS(text) {
17
- if (textCache.has(text)) {
18
- return textCache.get(text);
19
- }
20
-
21
  if (!text || typeof text !== 'string') {
22
  return '';
23
  }
24
 
25
- const cleaned = text
26
  .replace(/\*\*(.*?)\*\*/g, '$1')
27
  .replace(/__(.*?)__/g, '$1')
28
  .replace(/\*(.*?)\*/g, '$1')
@@ -40,13 +35,6 @@ function cleanTextForTTS(text) {
40
  .replace(/[\x00-\x1F\x7F-\x9F]/g, '')
41
  .replace(/\s+/g, ' ')
42
  .trim();
43
-
44
- // Cache apenas textos pequenos para não consumir muita RAM
45
- if (text.length < 500) {
46
- textCache.set(text, cleaned);
47
- }
48
-
49
- return cleaned;
50
  }
51
 
52
  async function processQueue() {
@@ -192,14 +180,6 @@ function streamAudio(text, lengthScale = 1.0, res) {
192
  }
193
  }
194
 
195
- // Limpar cache periodicamente para não consumir muita RAM
196
- setInterval(() => {
197
- if (textCache.size > 100) {
198
- textCache.clear();
199
- console.log('Cache de texto limpo');
200
- }
201
- }, 60000); // A cada minuto
202
-
203
  module.exports = { synthesizeAudio, streamAudio };
204
 
205
  /*
 
10
  let activeProcesses = 0;
11
  const requestQueue = [];
12
 
13
+ // Removido cache para simplificar
 
14
 
15
  function cleanTextForTTS(text) {
 
 
 
 
16
  if (!text || typeof text !== 'string') {
17
  return '';
18
  }
19
 
20
+ return text
21
  .replace(/\*\*(.*?)\*\*/g, '$1')
22
  .replace(/__(.*?)__/g, '$1')
23
  .replace(/\*(.*?)\*/g, '$1')
 
35
  .replace(/[\x00-\x1F\x7F-\x9F]/g, '')
36
  .replace(/\s+/g, ' ')
37
  .trim();
 
 
 
 
 
 
 
38
  }
39
 
40
  async function processQueue() {
 
180
  }
181
  }
182
 
 
 
 
 
 
 
 
 
183
  module.exports = { synthesizeAudio, streamAudio };
184
 
185
  /*