Exemple #1
0
    def __init__(self, videoPath, azureSpeechServiceKey, predictThreshold,
                 imageProcessingEndpoint, sendToHubCallback,
                 speechMapFileName):
        self.videoPath = videoPath

        self.predictThreshold = predictThreshold
        self.imageProcessingEndpoint = imageProcessingEndpoint
        self.imageProcessingParams = ""
        self.sendToHubCallback = sendToHubCallback

        if self.__IsInt(videoPath):
            # case of a usb camera (usually mounted at /dev/video* where * is an int)
            self.isWebcam = True

        self.vs = None

        self.speech_map = None
        self.speech_voice = 'en-US-GuyNeural'

        self.speech_map_filename = speechMapFileName

        if speechMapFileName is not None and os.path.isfile(
                self.speech_map_filename):
            with open(self.speech_map_filename, encoding='utf-8') as f:
                json_data = json.load(f)
                self.speech_voice = json_data.get('voice')
                self.speech_map = json_data.get('map')

        self.tts = text2speech.TextToSpeech(azureSpeechServiceKey,
                                            enableMemCache=True,
                                            enableDiskCache=True,
                                            voice=self.speech_voice)

        text = self.__localize_text('Starting scanner')
        self.tts.play('Starting scanner' if text is None else text)
    def __init__(self,
                 videoPath,
                 azureSpeechServiceKey,
                 predictThreshold,
                 imageProcessingEndpoint,
                 sendToHubCallback=None):
        self.videoPath = videoPath
        self.tts = text2speech.TextToSpeech(azureSpeechServiceKey)
        self.predictThreshold = predictThreshold
        self.imageProcessingEndpoint = imageProcessingEndpoint
        self.imageProcessingParams = ""
        self.sendToHubCallback = sendToHubCallback
        self.tts.play('Starting scanner')

        if self.__IsInt(videoPath):
            # case of a usb camera (usually mounted at /dev/video* where * is an int)
            self.isWebcam = True

        self.vs = None
def addArray(array, article):
    #rgb = (int(float(array[0])), int(float(array[1])), int(float(array[2])))
    rgb = tuple(array)
    hex_result = '%02x%02x%02x' % rgb
    print(hex_result)
    input = hex_result + ', ' + article
    item = getClosestColor(input)
    recommendation = item
    print(recommendation)
    value = recommendation[0].split(', ')
    color = value[0]
    item = value[1]
    print("Wear a " + webcolors.hex_to_name('#' + color) + " " + item)
    subscription_key = "3dcb81c95f9d46248813f574677f3272"
    app = text2speech.TextToSpeech(subscription_key,
                                   webcolors.hex_to_name('#' + color), article)
    app.get_token()
    app.save_audio("suggestion.wav")
    playsound('suggestion.wav')
Exemple #4
0
import text2speech

speech_voice = 'en-AU-Catherine'
azureSpeechServiceKey = ''

tts = text2speech.TextToSpeech(azureSpeechServiceKey,
                               enableMemCache=False,
                               enableDiskCache=False,
                               voice=speech_voice)

tts.play("hello world")
Exemple #5
0
import requests
import io
import os
import numpy as np
# import local devicecheck module
import devicecheck
import hubmanager
import oleddisplay
from iothub_client import IoTHubMessage
import text2speech

oled_display = None
hub = None
IMAGE_CLASSIFY_THRESHOLD = .95

tts = text2speech.TextToSpeech(os.getenv('BingKey'))


# Pull camera images and stream data to image classifier module.
def stream_camera_data(camera):
    while True:
        stream = io.BytesIO()
        camera.capture(stream, format='jpeg')
        stream.seek(0)
        image = {'imageData': stream}

        try:
            requests.post('http://image-classifier-service:80/image',
                          files=image,
                          hooks={'response': c_request_response})
        except Exception as e:
    if (object_.name == "Pants"):
        width, height = im.size
        # Cropped image of above dimension
        # (It will not change orginal image)
        im2 = im.crop((coord[0] * width, coord[1] * height, coord[2] * width,
                       coord[3] * height))
        im2.save("pant.png")

        path = "pant.png"
        with io.open(path, 'rb') as image_file:
            content = image_file.read()

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

        response = client.image_properties(image=image)
        props = response.image_properties_annotation
        pantColor = []
        for color in props.dominant_colors.colors:
            pantColor.append(format(color.color.red))
            pantColor.append(format(color.color.green))
            pantColor.append(format(color.color.blue))
            break
for color in topColor:
    print(color)
for color in pantColor:
    print(color)
subscription_key = "3dcb81c95f9d46248813f574677f3272"
app = text2speech.TextToSpeech(subscription_key, "purple", "shirt")
app.get_token()
app.save_audio()
playsound('sample.wav')
Exemple #7
0
    def __init__(self,
                 videoPath,
                 bingSpeechKey,
                 predictThreshold,
                 imageProcessingEndpoint="",
                 imageProcessingParams="",
                 showVideo=False,
                 verbose=True,
                 loopVideo=True,
                 convertToGray=False,
                 resizeWidth=0,
                 resizeHeight=0,
                 annotate=False,
                 sendToHubCallback=None):
        self.videoPath = videoPath
        if self.__IsInt(videoPath):
            # case of a usb camera (usually mounted at /dev/video* where * is an int)
            self.isWebcam = True
        else:
            # case of a video file
            self.isWebcam = False
        self.imageProcessingEndpoint = imageProcessingEndpoint
        if imageProcessingParams == "":
            self.imageProcessingParams = ""
        else:
            self.imageProcessingParams = json.loads(imageProcessingParams)
        self.showVideo = showVideo
        self.verbose = verbose
        self.loopVideo = loopVideo
        self.convertToGray = convertToGray
        self.resizeWidth = resizeWidth
        self.resizeHeight = resizeHeight
        self.annotate = (self.imageProcessingEndpoint !=
                         "") and self.showVideo & annotate
        self.nbOfPreprocessingSteps = 0
        self.autoRotate = False
        self.sendToHubCallback = sendToHubCallback
        self.vs = None
        self.tts = text2speech.TextToSpeech(bingSpeechKey)
        self.predictThreshold = predictThreshold

        if self.convertToGray:
            self.nbOfPreprocessingSteps += 1
        if self.resizeWidth != 0 or self.resizeHeight != 0:
            self.nbOfPreprocessingSteps += 1
        if self.verbose:
            print(
                "Initialising the camera capture with the following parameters: "
            )
            print("   - Video path: " + self.videoPath)
            print("   - Image processing endpoint: " +
                  self.imageProcessingEndpoint)
            print("   - Image processing params: " +
                  json.dumps(self.imageProcessingParams))
            print("   - Show video: " + str(self.showVideo))
            print("   - Loop video: " + str(self.loopVideo))
            print("   - Convert to gray: " + str(self.convertToGray))
            print("   - Resize width: " + str(self.resizeWidth))
            print("   - Resize height: " + str(self.resizeHeight))
            print("   - Annotate: " + str(self.annotate))
            print("   - Send processing results to hub: " +
                  str(self.sendToHubCallback is not None))
            print()