जैसा कि मैं स्विफ्ट भाषा में नया हूं, मुझे पता है कि माइक्रोसॉफ्ट एपीआई का उपयोग करके भाषण को टेक्स्ट में कैसे बदलना है, लेकिन क्लाइंट अनुरोध के हिस्से के रूप में मुझे इसे तेज भाषा में चाहिए। क्या कोई मेरी मदद कर सकता है कि इसे तेज भाषा में कैसे किया जाए। मैंने वह नमूना कोड भी जोड़ा जिसका मैंने उद्देश्य c . में उपयोग किया था

-(void)onFinalResponseReceived:(RecognitionResult*)response {
    bool isFinalDicationMessage = self.mode == SpeechRecognitionMode_LongDictation &&
    (response.RecognitionStatus == RecognitionStatus_EndOfDictation ||
     response.RecognitionStatus == RecognitionStatus_DictationEndSilenceTimeout);
    if (nil != micClient && self.useMicrophone && ((self.mode == SpeechRecognitionMode_ShortPhrase) || isFinalDicationMessage)) {
        // we got the final result, so it we can end the mic reco.  No need to do this
        // for dataReco, since we already called endAudio on it as soon as we were done
        // sending all the data.
        [micClient endMicAndRecognition];
    }

    if ((self.mode == SpeechRecognitionMode_ShortPhrase) || isFinalDicationMessage) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self startButton] setEnabled:YES];
        });
    }

    if (!isFinalDicationMessage) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self WriteLine:(@"********* Final n-BEST Results *********")];
            for (int i = 0; i < [response.RecognizedPhrase count]; i++) {
                RecognizedPhrase* phrase = response.RecognizedPhrase[i];
                [self WriteLine:[[NSString alloc] initWithFormat:(@"[%d] Confidence=%@ Text=\"%@\""),
                                 i,
                                 ConvertSpeechRecoConfidenceEnumToString(phrase.Confidence),
                                 phrase.DisplayText]];
            }

            [self WriteLine:(@"")];
        });
    }
}

//convert speech
OSStatus status = [micClient startMicAndRecognition];
        if (status) {
            [self WriteLine:[[NSString alloc] initWithFormat:(@"Error starting audio. %@"), 
ConvertSpeechErrorToString(status)]];
        }

NSString* ConvertSpeechErrorToString(int errorCode) {
    switch ((SpeechClientStatus)errorCode) {
        case SpeechClientStatus_SecurityFailed:         return @"SpeechClientStatus_SecurityFailed";
}
-1
user19 24 मई 2018, 07:57

1 उत्तर

सबसे बढ़िया उत्तर

ये कोशिश करें:

func onFinalResponseReceived(_ response: RecognitionResult?) {
    let isFinalDicationMessage: Bool = mode == SpeechRecognitionMode_LongDictation && (response?.recognitionStatus == RecognitionStatus_EndOfDictation || response?.recognitionStatus == RecognitionStatus_DictationEndSilenceTimeout)
    if nil != micClient && useMicrophone && ((mode == SpeechRecognitionMode_ShortPhrase) || isFinalDicationMessage) {
        // we got the final result, so it we can end the mic reco.  No need to do this
        // for dataReco, since we already called endAudio on it as soon as we were done
        // sending all the data.
        micClient.endMicAndRecognition()
    }
    if (mode == SpeechRecognitionMode_ShortPhrase) || isFinalDicationMessage {
        DispatchQueue.main.async(execute: {() -> Void in
            self.startButton().enabled = true
        })
    }
    if !isFinalDicationMessage {
        DispatchQueue.main.async(execute: {() -> Void in
            self.writeLine(("********* Final n-BEST Results *********"))
            var i = 0
            while i < response.recognizedPhrase.count() {
                var phrase: RecognizedPhrase? = response.recognizedPhrase[i]
                if let aText = phrase?.displayText {
                    self.writeLine(("[\(i)] Confidence=\(ConvertSpeechRecoConfidenceEnumToString(phrase?.confidence)) Text=\"\(aText)\""))
                }
                i
            }
            i += 1
            self.writeLine((""))
        })
    }
}

// edit:
var status: OSStatus = micClient.startMicAndRecognition()
func (int errorCode) -> String? {
    switch errorCode as? SpeechClientStatus {
    case SpeechClientStatus_SecurityFailed:
        return "SpeechClientStatus_SecurityFailed"
    }
}
2
Chanchal Chauhan 26 जुलाई 2019, 09:46