Skip to content

Commit

Permalink
recognition error 표기 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
miyaeyo committed Jan 18, 2017
1 parent 858bc2f commit 94647d1
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 42 deletions.
5 changes: 1 addition & 4 deletions AutoModeSample/AutoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ class AutoViewController: UIViewController {
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryRecord)
self.speechRecognizer.start(with: self.languages.selectedLanguage)
self.recognitionButton.isEnabled = false
self.statusLabel.text = "Connecting......"
}
}

// MARK: - property
@IBOutlet weak var languagePickerButton: UIButton!
@IBOutlet weak var recognitionResultLabel: UILabel!
@IBOutlet weak var recognitionButton: UIButton!
@IBOutlet weak var statusLabel: UILabel!

fileprivate let speechRecognizer: NSKRecognizer
fileprivate let languages = Languages()
Expand All @@ -105,7 +103,6 @@ extension AutoViewController: NSKRecognizerDelegate {
public func recognizerDidEnterReady(_ aRecognizer: NSKRecognizer!) {
print("Event occurred: Ready")

self.statusLabel.text = "Connected"
self.recognitionResultLabel.text = "Recognizing......"
self.setRecognitionButtonTitle(withText: "Stop", color: .red)
self.recognitionButton.isEnabled = true
Expand All @@ -120,7 +117,6 @@ extension AutoViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.statusLabel.text = ""
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient)
}

Expand All @@ -140,6 +136,7 @@ extension AutoViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.recognitionResultLabel.text = "Error: " + aError.localizedDescription
}

public func recognizer(_ aRecognizer: NSKRecognizer!, didReceive aResult: NSKRecognizedResult!) {
Expand Down
8 changes: 0 additions & 8 deletions AutoModeSample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,13 @@
<action selector="recognitionButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="aqT-Pg-zlI"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DbG-pq-gVF">
<rect key="frame" x="79" y="521" width="217" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="languagePickerButton" destination="h2X-EX-Ekk" id="mW5-ZU-A9b"/>
<outlet property="recognitionButton" destination="f8T-yc-74W" id="o0B-pl-D4H"/>
<outlet property="recognitionResultLabel" destination="x7b-8O-LXY" id="Y7y-Ge-e6e"/>
<outlet property="statusLabel" destination="DbG-pq-gVF" id="wtm-da-N6d"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
8 changes: 0 additions & 8 deletions HybridModeSample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,13 @@
<color key="titleColor" red="0.0" green="0.0" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ksk-IM-Gcs">
<rect key="frame" x="79" y="523" width="217" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="languagePickerButton" destination="6iR-oq-SSk" id="Eqs-pr-PqB"/>
<outlet property="recognitionButton" destination="5Rd-li-bW7" id="c73-tG-ALu"/>
<outlet property="recognitionResultLabel" destination="QQc-Tj-9Ke" id="2Wi-oj-sXt"/>
<outlet property="statusLabel" destination="ksk-IM-Gcs" id="4rt-h3-zdz"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
5 changes: 1 addition & 4 deletions HybridModeSample/HybridViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class HybridViewController: UIViewController {
self.epdType = .hybrid
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryRecord)
self.speechRecognizer.start(with: self.languages.selectedLanguage)
self.statusLabel.text = "Connecting........"

} else if self.epdType == .auto {
self.speechRecognizer.stop()
Expand All @@ -115,7 +114,6 @@ class HybridViewController: UIViewController {
@IBOutlet weak var languagePickerButton: UIButton!
@IBOutlet weak var recognitionResultLabel: UILabel!
@IBOutlet weak var recognitionButton: UIButton!
@IBOutlet weak var statusLabel: UILabel!

fileprivate let speechRecognizer: NSKRecognizer
fileprivate let languages = Languages()
Expand All @@ -131,7 +129,6 @@ extension HybridViewController: NSKRecognizerDelegate {
public func recognizerDidEnterReady(_ aRecognizer: NSKRecognizer!) {
print("Event occurred: Ready")

self.statusLabel.text = "Connected"
self.recognitionResultLabel.text = "Recognizing......"
self.recognitionButton.isEnabled = true
}
Expand All @@ -145,7 +142,6 @@ extension HybridViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.statusLabel.text = ""
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient)
}

Expand Down Expand Up @@ -182,6 +178,7 @@ extension HybridViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.recognitionResultLabel.text = "Error: " + aError.localizedDescription
}

public func recognizer(_ aRecognizer: NSKRecognizer!, didReceive aResult: NSKRecognizedResult!) {
Expand Down
8 changes: 0 additions & 8 deletions ManualModeSample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,13 @@
<color key="titleColor" red="0.0" green="0.0" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gju-8b-5dG">
<rect key="frame" x="79" y="522" width="217" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="languagePickerButton" destination="KBy-K3-YNh" id="5BI-IV-3Oz"/>
<outlet property="recognitionButton" destination="P9O-g4-FGs" id="J43-ka-IUi"/>
<outlet property="recognitionResultLabel" destination="NTB-rx-eK9" id="vK4-6X-IVl"/>
<outlet property="statusLabel" destination="Gju-8b-5dG" id="2Ka-2N-t6o"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
5 changes: 1 addition & 4 deletions ManualModeSample/ManualViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class ManualViewController: UIViewController {
if sender.state == .began {
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryRecord)
self.speechRecognizer.start(with: self.languages.selectedLanguage)
self.statusLabel.text = "Connecting......."
} else if sender.state == .ended {
self.speechRecognizer.stop()
}
Expand All @@ -90,7 +89,6 @@ class ManualViewController: UIViewController {
@IBOutlet weak var languagePickerButton: UIButton!
@IBOutlet weak var recognitionResultLabel: UILabel!
@IBOutlet weak var recognitionButton: UIButton!
@IBOutlet weak var statusLabel: UILabel!

fileprivate let speechRecognizer: NSKRecognizer
fileprivate let languages = Languages()
Expand All @@ -105,7 +103,6 @@ extension ManualViewController: NSKRecognizerDelegate {
public func recognizerDidEnterReady(_ aRecognizer: NSKRecognizer!) {
print("Event occurred: Ready")

self.statusLabel.text = "Connected"
self.recognitionResultLabel.text = "Recognizing......"
self.setRecognitionButtonTitle(withText: "Recognizing", color: .red)
self.recognitionButton.isEnabled = true
Expand All @@ -120,7 +117,6 @@ extension ManualViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.statusLabel.text = ""
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient)
}

Expand All @@ -140,6 +136,7 @@ extension ManualViewController: NSKRecognizerDelegate {

self.setRecognitionButtonTitle(withText: "Record", color: .blue)
self.recognitionButton.isEnabled = true
self.recognitionResultLabel.text = "Error: " + aError.localizedDescription
}

public func recognizer(_ aRecognizer: NSKRecognizer!, didReceive aResult: NSKRecognizedResult!) {
Expand Down
12 changes: 6 additions & 6 deletions NaverSpeechSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = ManualModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.ManualModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -581,7 +581,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = ManualModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.ManualModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -605,7 +605,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = HybridModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.HybridModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -631,7 +631,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = HybridModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.HybridModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -655,7 +655,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = AutoModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.AutoModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -681,7 +681,7 @@
"$(PROJECT_DIR)/framework",
);
INFOPLIST_FILE = AutoModeSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.navercorp.AutoModeSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down

0 comments on commit 94647d1

Please sign in to comment.