21 lines
848 B
Python
21 lines
848 B
Python
import os
|
|
import json
|
|
|
|
import speech_recognition
|
|
import speech_synthesis
|
|
import chatgpt
|
|
import record_audio
|
|
|
|
if __name__ == "__main__":
|
|
dirname = os.path.dirname(__file__)
|
|
with open(os.path.join(dirname, "config.json")) as config_file:
|
|
config = json.load(config_file)
|
|
openai_key=config['OPENAI_KEY']
|
|
record_audio.record(dirname,
|
|
device_id=config["MIC_DEVICE_ID"],
|
|
max_recording_time_s=config["SECONDS_RECORDING"])
|
|
transcribed = speech_recognition.transcribe(dirname, openai_key)
|
|
answer = chatgpt.chat(transcribed, openai_key)
|
|
#Idea: recognize language and pass it to speech synthesizer. Unfortunately the detected language currently not returned by the OpenAI API
|
|
speech_synthesis.speak(answer, voice=config["ESPEAK_VOICE"])
|
|
|