forked from open-webui/open-webui
		
	feat: merge one word sentence
This commit is contained in:
		
							parent
							
								
									f01428f502
								
							
						
					
					
						commit
						66f86062b8
					
				
					 1 changed files with 16 additions and 1 deletions
				
			
		|  | @ -151,7 +151,22 @@ | ||||||
| 			if ($settings?.speech?.engine === 'openai') { | 			if ($settings?.speech?.engine === 'openai') { | ||||||
| 				loadingSpeech = true; | 				loadingSpeech = true; | ||||||
| 
 | 
 | ||||||
| 				const sentences = extractSentences(message.content); | 				const sentences = extractSentences(message.content).reduce((mergedTexts, currentText) => { | ||||||
|  | 					const lastIndex = mergedTexts.length - 1; | ||||||
|  | 					if (lastIndex >= 0) { | ||||||
|  | 						const previousText = mergedTexts[lastIndex]; | ||||||
|  | 						const wordCount = previousText.split(/\s+/).length; | ||||||
|  | 						if (wordCount < 2) { | ||||||
|  | 							mergedTexts[lastIndex] = previousText + ' ' + currentText; | ||||||
|  | 						} else { | ||||||
|  | 							mergedTexts.push(currentText); | ||||||
|  | 						} | ||||||
|  | 					} else { | ||||||
|  | 						mergedTexts.push(currentText); | ||||||
|  | 					} | ||||||
|  | 					return mergedTexts; | ||||||
|  | 				}, []); | ||||||
|  | 
 | ||||||
| 				console.log(sentences); | 				console.log(sentences); | ||||||
| 
 | 
 | ||||||
| 				sentencesAudio = sentences.reduce((a, e, i, arr) => { | 				sentencesAudio = sentences.reduce((a, e, i, arr) => { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek