示例#1
0
def main() :
  voice.speech("지금부터 퀴즈를 시작하겠습니다. 힌트를 듣고 정답을 말해주세요")
  quiz_answer, quiz_hint = get_random_quiz() #랜덤 퀴즈를 받아옵니다.
  # 랜덤 퀴즈를 입력해주고 퀴즈 결과 점수를 받아옵니다
  result_score = solve_quiz(quiz_answer, quiz_hint)
  # 점수를 음성출력해줍니다.
  voice.speech("점수는 %d점 입니다."%result_score)
示例#2
0
def solve_quiz(quiz_answer, quiz_hint) :
  score = 10 # 초기 점수를 10으로 설정합니다.

  # for문을 사용하여 힌트를 하나씩 가져옵니다.
  for hint in quiz_hint :
    # 몇번째 힌트인지 안내합니다.
    voice.speech("%d번 힌트 입니다."%(quiz_hint.index(hint)+1))
    # 힌트를 음성출력합니다.
    voice.speech(hint)
    # STT를 통해 정답을 인식합니다.
    input_text = voice.get_text_from_voice()
    # 인식된 결과가 정답일 경우 정답이라고 말하고 점수를 리턴합니다.
    if input_text.find(quiz_answer) != -1 :
      voice.speech("정답입니다.")
      return score
    # 인식된 결과가 없거나 다음이라고 인식되면 1점을 감점하고 다음힌트를 출력합니다.
    elif input_text == "" or input_text.find("다음") != -1 :
      voice.speech("땡 오답입니다.")
      score -= 1
      continue
    # 인식된 답이 틀린 답이라면 2점을 감점합니다.
    else :
      voice.speech("땡 오답입니다.")
      score -= 2
      continue
  # 끝까지 정답을 인식하지 못한 경우에는 정답을 안내하고 점수를 리턴합니다.
  else :
    answer_text = "정답은 %s입니다."%quiz_answer
    return score
    print(answer_text)
示例#3
0
def main():
    while True:
        if voice.detect_wake_up_word():
            input_text = voice.get_text_from_voice()
            print(input_text)  #voice 출력 문자열
            if input_text.find("날씨") != -1:  #날씨 문자열이 있을경우
                weather.main()
            elif input_text.find("냉장고") != -1:  #냉장고 문자열이 있을경우
                food_recognize.main()
            else:
                result_answer = voice.query_by_text(input_text)
                voice.speech(result_answer)  #다시 말씀해 주세요
示例#4
0
def main():
    while True:
        if voice.detect_wake_up_word():
            input_text = voice.get_text_from_voice()
            print(input_text)
            if input_text.find("퀴즈 게임 시작해 줘") != -1:
                quiz_game.main()
            elif input_text.find("타이머 시작해 줘") != -1:
                timer.main()
            elif input_text.find("날씨 알려줘") != -1:
                weather.main()
            elif input_text.find("사전 시작해 줘") != -1:
                dictionary.main()
            elif input_text.find("외부 제어 시작해 줘") != -1:
                control.main()
            elif input_text.find("외부 센서 실행해 줘") != -1:
                sensor.main()
            else:
                result_answer = voice.query_by_text(input_text)
                voice.speech(result_answer)
示例#5
0
def recognize_food(img_path, list_foods):
    start_time = datetime.now()

    # opencv로 이미지 읽기
    img = cv2.imread(img_path)

    # 이미지 크기 가져오기
    height, width = img.shape[:2]

    # 이미지 축적
    img = cv2.resize(img, (800, int((height * 800) / width)))

    # 임시 파일에 이미지 저장
    cv2.imwrite(SOURCE_PATH + "output.jpg", img)

    # google vision에 대한 새로운 img 경로 만들기
    img_path = SOURCE_PATH + "output.jpg"

    # Google 비전 클라이언트 만들기
    client = vision.ImageAnnotatorClient()

    # 이미지 파일 읽기
    with io.open(img_path, 'rb') as image_file:
        content = image_file.read()

    image = vision.types.Image(content=content)

    response = client.label_detection(image=image)
    labels = response.label_annotations

    for label in labels:
        desc = label.description.lower()
        score = round(label.score, 2)
        print("label: ", desc, "  score: ", score)  #과일이름 정확도
        if (desc in list_foods):

            voice.speech("%s가 있습니다." % desc.upper())  #정확도 높은 순으로 과일이름 출력
            # Get first fruit only
            break
def main():
    voice.speech("조명을 제어합니다. 켜줘 또는 꺼줘로 제어해보세요")
    input_text = voice.get_text_from_voice()  # TTS를 실행하여 텍스트를 받아옵니다.
    result_target = get_target_status(input_text)  # 입력된 텍스트를 입력해 명령을 구분합니다.
    # 구분된 명령을 발행하고 결과를 받아옵니다.
    publish_result = publish_target_status(result_target)

    # 구분된 명령과 발행된 결과값을 처리하여 음성으로 출력합니다.
    if publish_result == True:
        if result_target == "HIGH":
            voice.speech("조명을 켭니다.")
        elif result_target == "LOW":
            voice.speech("조명을 끕니다.")
    else:
        voice.speech("잘못된 명령이 인식되었습니다.")
def main():
    voice.speech('궁금하신 단어가 무엇인가요?')
    word = voice.get_text_from_voice()
    meanings = searchKorean(word)

    if meanings == None or len(meanings) == 0:
        voice.speech('%s에 관한 뜻을 찾지 못했어요.' % word)
    else:
        voice.speech('사전에서 찾은 검색결과입니다. %s' % meanings[0])
def main():
    voice.speech("어디의 날씨를 알려드릴까요?")
    address = voice.get_text_from_voice()

    coord = map.get_coord_by_address(address)
    if coord == None:
        voice.speech("%s을 찾지 못했습니다." % address)
    else:
        weather_info = get_weather_by_coord(coord[0], coord[1])

        response_text = create_weather_text(weather_info, address)
        voice.speech(response_text)
示例#9
0
def main():
    voice.speech("어디의 날씨를 알려드릴까요?")
    address = voice.get_text_from_voice()

    coord = map.get_coord_by_address(address)  #존재하는 도시인지 체크
    if coord == None:  #지역이 없을경우
        voice.speech("%s을 찾지 못했습니다." % address)
    else:
        weather_info = get_weather_by_coord(coord[0],
                                            coord[1])  # 경도와 위도 정보 가져오기

        response_text = create_weather_text(weather_info,
                                            address)  #weater_info 온도,습도 주소 말하기
        voice.speech(response_text)
示例#10
0
def start_timer(input_text):
    hms = [0, 0, 0]
    if input_text.find("타이머") != -1:
        for word in input_text.split(" "):
            if word.find("시간") != -1:
                hour = int(word.replace("시간", ""))
                hms[0] = hour
            elif word.find("분") != -1:
                minute = int(word.replace("분", ""))
                hms[1] = minute
            elif word.find("초") != -1:
                second = int(word.replace("초", ""))
                hms[2] = second
        print(hms)
        voice.speech("타이머가 %d시간 %d분 %d초로 설정됩니다." % (hms[0], hms[1], hms[2]))
        timer_sec = hms[0] * 3600 + hms[1] * 60 + hms[2]
        print(timer_sec)
        time.sleep(timer_sec)
        print("timer end")
        voice.speech("땡땡땡 타이머가 종료되었습니다.")
    else:
        voice.speech("타이머가 설정되지 않았습니다.")
示例#11
0
def main():
    voice.speech("타이머를 시작합니다. 설정할 시간을 말해주세요")
    input_text = voice.get_text_from_voice()
    start_timer(input_text)
def main():
	voice.speech("연결된 센서의 측정 값을 알려드리겠습니다.")
	result_message = subscribe_message()
	voice.speech(result_message)