示例#1
0
    public void PlayTextToSpeechMessage(MCSComputerVisionOCRDto computerVisionOCR)
    {
        string message = string.Empty;

        if (string.IsNullOrEmpty(computerVisionOCR.text))
        {
            message = "I couldn't detect text";
        }
        else
        {
            message = string.Format("The text says, {0}", computerVisionOCR.text);
        }

        // Try and get a TTS Manager
        TextToSpeech tts = null;

        if (photoCaptureManagerGmObj != null)
        {
            tts = photoCaptureManagerGmObj.GetComponent <TextToSpeech>();
        }

        if (tts != null)
        {
            //Play voice message
            tts.StartSpeaking(message);
        }
    }
    private void SaveJsonToTextModel(JSONObject j)
    {
        List <string> wordList  = new List <string>();
        string        textAngle = string.Empty;

        try { textAngle = j.GetField("textAngle").ToString(); }
        catch { }

        //Add computerVisionOCRDto
        MCSComputerVisionOCRDto computerVisionOCR = new MCSComputerVisionOCRDto()
        {
            language    = j.GetField("language").ToString(),
            textAngle   = textAngle,
            orientation = j.GetField("orientation").ToString()
        };

        //Add region, words
        var region = j.GetField("regions");

        if (region.list.Count != 0)
        {
            foreach (var regionItem in region.list)
            {
                var lines = regionItem.GetField("lines");
                foreach (var line in lines.list)
                {
                    var words = line.GetField("words");
                    foreach (var word in words.list)
                    {
                        wordList.Add(word.GetField("text").ToString().Replace("\"", ""));
                    }
                }
            }
        }

        computerVisionOCR.text = string.Join(" ", wordList.ToArray());

        PlayVoiceMessage.Instance.PlayTextToSpeechMessage(computerVisionOCR);
    }