audio
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 52s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 52s
				
			This commit is contained in:
		
							parent
							
								
									ef15f5894e
								
							
						
					
					
						commit
						7f89c584c0
					
				| @ -298,52 +298,52 @@ func (s *LLMService) handleStreamingResponse(req *http.Request, data map[string] | |||||||
| 				// fmt.Println("new_message", new_message) | 				// fmt.Println("new_message", new_message) | ||||||
| 
 | 
 | ||||||
| 				// 最多重试一次 | 				// 最多重试一次 | ||||||
| 				// for i := 0; i < 1; i++ { | 				for i := 0; i < 1; i++ { | ||||||
| 				// 	speechResp, err := s.SynthesizeSpeech(new_message, audio_type) | 					speechResp, err := s.SynthesizeSpeech(new_message, audio_type) | ||||||
| 				// 	if err != nil { | 					if err != nil { | ||||||
| 				// 		fmt.Printf("Error synthesizing speech: %v\n", err) | 						fmt.Printf("Error synthesizing speech: %v\n", err) | ||||||
| 				// 		break // 语音接口报错直接跳出 | 						break // 语音接口报错直接跳出 | ||||||
| 				// 	} | 					} | ||||||
| 				// 	fmt.Println("语音:", speechResp) | 					fmt.Println("语音:", speechResp) | ||||||
| 				// 	audio = speechResp.Data.Audio | 					audio = speechResp.Data.Audio | ||||||
| 				// 	if audio != "" { | 					if audio != "" { | ||||||
| 				// 		// Download audio from URL and trim silence | 						// Download audio from URL and trim silence | ||||||
| 				// 		resp, err := http.Get(audio) | 						resp, err := http.Get(audio) | ||||||
| 				// 		if err != nil { | 						if err != nil { | ||||||
| 				// 			fmt.Printf("Error downloading audio: %v\n", err) | 							fmt.Printf("Error downloading audio: %v\n", err) | ||||||
| 				// 		} else { | 						} else { | ||||||
| 				// 			defer resp.Body.Close() | 							defer resp.Body.Close() | ||||||
| 				// 			audioBytes, err := io.ReadAll(resp.Body) | 							audioBytes, err := io.ReadAll(resp.Body) | ||||||
| 				// 			if err != nil { | 							if err != nil { | ||||||
| 				// 				fmt.Printf("Error reading audio data: %v\n", err) | 								fmt.Printf("Error reading audio data: %v\n", err) | ||||||
| 				// 			} else { | 							} else { | ||||||
| 				// 				// Save original audio first | 								// Save original audio first | ||||||
| 				// 				originalPath := fmt.Sprintf("audio/original_%d.wav", time.Now().UnixNano()) | 								originalPath := fmt.Sprintf("audio/original_%d.wav", time.Now().UnixNano()) | ||||||
| 				// 				if err := os.WriteFile(originalPath, audioBytes, 0644); err != nil { | 								if err := os.WriteFile(originalPath, audioBytes, 0644); err != nil { | ||||||
| 				// 					fmt.Printf("Error saving original audio: %v\n", err) | 									fmt.Printf("Error saving original audio: %v\n", err) | ||||||
| 				// 				} | 								} | ||||||
| 
 | 
 | ||||||
| 				// 				// Convert audio bytes to base64 for processing | 								// Convert audio bytes to base64 for processing | ||||||
| 				// 				audioBase64 := base64.StdEncoding.EncodeToString(audioBytes) | 								audioBase64 := base64.StdEncoding.EncodeToString(audioBytes) | ||||||
| 				// 				trimmedAudio, err := s.TrimAudioSilence(audioBase64) | 								trimmedAudio, err := s.TrimAudioSilence(audioBase64) | ||||||
| 				// 				if err != nil { | 								if err != nil { | ||||||
| 				// 					fmt.Printf("Error trimming audio silence: %v\n", err) | 									fmt.Printf("Error trimming audio silence: %v\n", err) | ||||||
| 				// 				} else { | 								} else { | ||||||
| 				// 					// Save the trimmed audio as WAV file | 									// Save the trimmed audio as WAV file | ||||||
| 				// 					audio_path := fmt.Sprintf("trimmed_%d.wav", time.Now().UnixNano()) | 									audio_path := fmt.Sprintf("trimmed_%d.wav", time.Now().UnixNano()) | ||||||
| 				// 					outputPath := "audio/" + audio_path | 									outputPath := "audio/" + audio_path | ||||||
| 				// 					if err := s.SaveBase64AsWAV(trimmedAudio, outputPath); err != nil { | 									if err := s.SaveBase64AsWAV(trimmedAudio, outputPath); err != nil { | ||||||
| 				// 						fmt.Printf("Error saving trimmed WAV file: %v\n", err) | 										fmt.Printf("Error saving trimmed WAV file: %v\n", err) | ||||||
| 				// 					} | 									} | ||||||
| 				// 					audio = s.config.FILE_URL + audio_path | 									audio = s.config.FILE_URL + audio_path | ||||||
| 				// 				} | 								} | ||||||
| 				// 			} | 							} | ||||||
| 				// 		} | 						} | ||||||
| 				// 		break // 获取到音频就退出 | 						break // 获取到音频就退出 | ||||||
| 				// 	} | 					} | ||||||
| 				// 	fmt.Println("audio is empty, retry", speechResp) | 					fmt.Println("audio is empty, retry", speechResp) | ||||||
| 				// 	// time.Sleep(1 * time.Second) | 					// time.Sleep(1 * time.Second) | ||||||
| 				// } | 				} | ||||||
| 
 | 
 | ||||||
| 				messageChan <- Message{ | 				messageChan <- Message{ | ||||||
| 					Answer:         new_message, | 					Answer:         new_message, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Song367
						Song367