Skip to content

Instantly share code, notes, and snippets.

@maax-cha
Created April 25, 2024 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maax-cha/d4ff41265a9bd27f14410ded69f76a64 to your computer and use it in GitHub Desktop.
Save maax-cha/d4ff41265a9bd27f14410ded69f76a64 to your computer and use it in GitHub Desktop.
Ai Makers Kit 142페이지 예제 fix
"""
AMK Python API가 변경되며 교재의 코드가 호환되지 않습니다.
예제의 ex로 시작하는 예제는 이에 맞게 변경되어 있어 이러한 예제를 그대로 활용하도록 코드를 수정하였습니다.
"""
import MicrophoneStream as MS
import ex1_kwstest
import ex2_getVoice2Text
import ex4_getText2VoiceStream
import ex6_queryVoice
def detect_wake_up_word(keyword="기가지니"):
return ex1_kwstest.test(keyword)
def get_text_from_voice():
return ex2_getVoice2Text.getVoice2Text()
def get_voice_from_text(text, output_file_name="tts.wav"):
return ex4_getText2VoiceStream.getText2VoiceStream(text, output_file_name)
def speech(text):
get_voice_from_text(text)
MS.play_file("tts.wav")
print("음성이 출력되었습니다.")
def query_by_text(text):
return ex6_queryVoice.queryByVoice()
if __name__ == "__main__":
if detect_wake_up_word():
recognized_text = get_text_from_voice()
result = query_by_text(recognized_text)
print(result)
speech(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment