#!/usr/bin/env python

from __future__ import print_function
import rospy
from std_msgs.msg import String

togglePub = rospy.Publisher('toggle', String, queue_size=10)



def callback(data):
    print(data)

def main():
    rospy.init_node('sound_test_node')

    rate = rospy.Rate(1)
    rate.sleep()

    confirmed = False
    print("Tell me something")

    while(not confirmed):

        toggle = "on"
        togglePub.publish(toggle)
        
        try:
            recognized = rospy.wait_for_message("/recognizer/output", String)
        except Exception as e:
            print(e)

        print("I heard" , recognized.data, "Is that correct?")

        try:
            recognized = rospy.wait_for_message("/recognizer/output", String)
        except Exception as e:
            print(e)

        if recognized.data == "yes":
            print("proceeding...")
            confirmed = True
        else:
            print("Please repeat that..")

        toggle = "off"
        togglePub.publish(toggle)

    rospy.spin()

        
   

if __name__ == '__main__':
    main()
