forked from React-Group/interstellar_ai
		
	TTS
This commit is contained in:
		
							parent
							
								
									a6699924c8
								
							
						
					
					
						commit
						42b12f73b4
					
				
					 3 changed files with 20 additions and 1 deletions
				
			
		|  | @ -6,6 +6,7 @@ from ai import AI | ||||||
| from db import DB | from db import DB | ||||||
| from weather import Weather | from weather import Weather | ||||||
| from voice import VoiceRecognition | from voice import VoiceRecognition | ||||||
|  | from tts import TTS | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class API: | class API: | ||||||
|  | @ -17,6 +18,7 @@ class API: | ||||||
|         self.db = DB() |         self.db = DB() | ||||||
|         self.weather = Weather() |         self.weather = Weather() | ||||||
|         self.voice = VoiceRecognition() |         self.voice = VoiceRecognition() | ||||||
|  |         self.tts = TTS() | ||||||
|         self.db.load_database() |         self.db.load_database() | ||||||
|         self.ai_response_lock = threading.Lock() |         self.ai_response_lock = threading.Lock() | ||||||
|         CORS(self.app) |         CORS(self.app) | ||||||
|  | @ -113,6 +115,11 @@ class API: | ||||||
| 
 | 
 | ||||||
|         self.app.run(debug=True, host='0.0.0.0', port=5000) |         self.app.run(debug=True, host='0.0.0.0', port=5000) | ||||||
| 
 | 
 | ||||||
|  |         @self.app.route('/interstellar_ai/api/tts', methods=['POST']) | ||||||
|  |         def tts(): | ||||||
|  |             text = request.args.get('text') | ||||||
|  |             return jsonify({'status': 200, 'response': self.tts.gen_tts(text)}) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| api = API() | api = API() | ||||||
| api.run() | api.run() | ||||||
|  |  | ||||||
|  | @ -11,3 +11,5 @@ google-cloud-speech | ||||||
| google-generativeai | google-generativeai | ||||||
| python-weather | python-weather | ||||||
| pycouchdb | pycouchdb | ||||||
|  | pyttsx3 | ||||||
|  | pip-licenses | ||||||
							
								
								
									
										10
									
								
								py/tts.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								py/tts.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | import pyttsx3 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class TTS: | ||||||
|  |     @staticmethod | ||||||
|  |     def gen_tts(text): | ||||||
|  |         engine = pyttsx3.init() | ||||||
|  |         engine.setProperty('rate', 70) | ||||||
|  |         engine.say(text) | ||||||
|  |         engine.runAndWait() | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Patrick_Pluto
						Patrick_Pluto