Skip to content

Commit 6cbe427

Browse files
committed
Updated help menu
1 parent 10f3e7c commit 6cbe427

4 files changed

Lines changed: 56 additions & 67 deletions

File tree

newDemo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ Key Words:
3939
Go To:
4040
Move to a different class or method
4141
"Go To <Class or method name> stop"
42+
4243
Exit:
4344
Exit a control structure
4445
"exit stop"
46+
4547
Clear:
4648
Clear the current input
4749
"Clear stop"

textToCode/textToCode/Base.lproj/Main.storyboard

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina5_5" orientation="portrait">
3+
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
@@ -15,11 +15,11 @@
1515
<objects>
1616
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="textToCode" customModuleProvider="target" sceneMemberID="viewController">
1717
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
18-
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1919
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2020
<subviews>
2121
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" keyboardDismissMode="onDrag" text="Output text here" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ijO-W5-OfQ">
22-
<rect key="frame" x="20" y="74" width="374" height="503"/>
22+
<rect key="frame" x="16" y="74" width="343" height="434"/>
2323
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
2424
<accessibility key="accessibilityConfiguration">
2525
<accessibilityTraits key="traits" updatesFrequently="YES" allowsDirectInteraction="YES"/>
@@ -28,7 +28,7 @@
2828
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" smartDashesType="no" smartQuotesType="no"/>
2929
</textView>
3030
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="Best Transcription here" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="8z6-6C-Bnu">
31-
<rect key="frame" x="20" y="593" width="374" height="100"/>
31+
<rect key="frame" x="16" y="524" width="343" height="100"/>
3232
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
3333
<constraints>
3434
<constraint firstAttribute="height" constant="100" id="Wej-y6-sce"/>
@@ -37,35 +37,38 @@
3737
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
3838
</textView>
3939
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vcT-EK-v3K">
40-
<rect key="frame" x="182.66666666666666" y="699" width="49" height="30"/>
40+
<rect key="frame" x="163" y="630" width="49" height="30"/>
4141
<state key="normal" title="SHARE"/>
4242
<connections>
4343
<action selector="share:" destination="BYZ-38-t0r" eventType="touchUpInside" id="62H-BQ-CFc"/>
4444
</connections>
4545
</button>
4646
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4xR-aT-o8z">
47-
<rect key="frame" x="182.66666666666666" y="28" width="49" height="30"/>
47+
<rect key="frame" x="163" y="28" width="49" height="30"/>
4848
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4949
<state key="normal" title="Record"/>
5050
<connections>
5151
<action selector="recordPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jlZ-vr-VSt"/>
5252
</connections>
5353
</button>
5454
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="55" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="umQ-ya-di6">
55-
<rect key="frame" x="20" y="37.666666666666664" width="20.333333333333329" height="20.333333333333336"/>
55+
<rect key="frame" x="20" y="37.5" width="20.5" height="20.5"/>
5656
<fontDescription key="fontDescription" type="system" pointSize="17"/>
5757
<nil key="textColor"/>
5858
<nil key="highlightedColor"/>
5959
</label>
6060
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uHW-TC-1Pc">
61-
<rect key="frame" x="362" y="28" width="32" height="30"/>
61+
<rect key="frame" x="323" y="28" width="32" height="30"/>
62+
<constraints>
63+
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="32" id="to3-G1-Tmk"/>
64+
</constraints>
6265
<state key="normal" title="Help"/>
6366
<connections>
6467
<segue destination="dbO-uL-s87" kind="show" id="du0-NS-8H8"/>
6568
</connections>
6669
</button>
6770
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sqh-YK-hDD">
68-
<rect key="frame" x="285" y="28" width="44" height="30"/>
71+
<rect key="frame" x="246" y="28" width="44" height="30"/>
6972
<constraints>
7073
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="44" id="RWq-sq-01a"/>
7174
</constraints>
@@ -116,35 +119,27 @@
116119
<objects>
117120
<viewController id="dbO-uL-s87" sceneMemberID="viewController">
118121
<view key="view" contentMode="scaleToFill" id="4PP-LI-6xs">
119-
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
122+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
120123
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
121124
<subviews>
122-
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DtM-Mo-ib8">
123-
<rect key="frame" x="26" y="20" width="34" height="30"/>
124-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
125-
<state key="normal" title="Back"/>
126-
<connections>
127-
<segue destination="BYZ-38-t0r" kind="show" id="RCb-e2-it3"/>
128-
</connections>
129-
</button>
130-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Help Menu" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e6R-r8-ZQX">
131-
<rect key="frame" x="144" y="46" width="127" height="45"/>
132-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
125+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Help Menu" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e6R-r8-ZQX">
126+
<rect key="frame" x="129" y="46" width="117.5" height="30"/>
133127
<fontDescription key="fontDescription" type="system" pointSize="25"/>
134128
<nil key="textColor"/>
135129
<nil key="highlightedColor"/>
136130
</label>
137-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Jc0-6G-14K">
138-
<rect key="frame" x="20" y="99" width="356" height="517"/>
139-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
131+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jc0-6G-14K">
132+
<rect key="frame" x="20" y="84" width="339" height="563"/>
140133
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
141134
<mutableString key="text">Key Words:
142135
Go To:
143136
Move to a different class or method
144137
"Go To &lt;Class or method name&gt; stop"
138+
145139
Exit:
146140
Exit a control structure
147141
"exit stop"
142+
148143
Clear:
149144
Clear the current input
150145
"Clear stop"
@@ -189,18 +184,41 @@ Make a return Statement:
189184
"return &lt;returnValue&gt; stop"
190185

191186
Make a print Statement:
192-
"Print &lt;returnValue&gt; stop"</mutableString>
193-
<fontDescription key="fontDescription" type="system" pointSize="14"/>
187+
"Print &lt;returnValue&gt; stop"
188+
</mutableString>
189+
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
190+
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="14"/>
194191
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
195192
</textView>
193+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DtM-Mo-ib8">
194+
<rect key="frame" x="20" y="28" width="34" height="30"/>
195+
<state key="normal" title="Back"/>
196+
<connections>
197+
<segue destination="BYZ-38-t0r" kind="show" id="RCb-e2-it3"/>
198+
</connections>
199+
</button>
196200
</subviews>
197201
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
202+
<constraints>
203+
<constraint firstItem="DtM-Mo-ib8" firstAttribute="top" secondItem="Bh0-gj-RGd" secondAttribute="top" constant="8" id="29P-1n-636"/>
204+
<constraint firstItem="Bh0-gj-RGd" firstAttribute="bottom" secondItem="Jc0-6G-14K" secondAttribute="bottom" constant="20" id="72p-ZM-V5q"/>
205+
<constraint firstItem="Jc0-6G-14K" firstAttribute="top" secondItem="e6R-r8-ZQX" secondAttribute="bottom" constant="8" id="Ex0-Dm-bKf"/>
206+
<constraint firstItem="e6R-r8-ZQX" firstAttribute="leading" secondItem="DtM-Mo-ib8" secondAttribute="trailing" constant="75" id="Hid-5c-a7k"/>
207+
<constraint firstItem="e6R-r8-ZQX" firstAttribute="top" secondItem="Bh0-gj-RGd" secondAttribute="top" constant="26" id="KRJ-zr-fCM"/>
208+
<constraint firstItem="Jc0-6G-14K" firstAttribute="top" secondItem="DtM-Mo-ib8" secondAttribute="bottom" constant="26" id="SJk-ON-CaZ"/>
209+
<constraint firstItem="e6R-r8-ZQX" firstAttribute="leading" secondItem="DtM-Mo-ib8" secondAttribute="trailing" constant="75" id="VXH-MO-aAY"/>
210+
<constraint firstItem="Bh0-gj-RGd" firstAttribute="trailing" secondItem="e6R-r8-ZQX" secondAttribute="trailing" constant="128.5" id="WgB-Zk-fdg"/>
211+
<constraint firstItem="Jc0-6G-14K" firstAttribute="top" secondItem="e6R-r8-ZQX" secondAttribute="bottom" constant="8" id="cbQ-Fm-Ati"/>
212+
<constraint firstItem="Bh0-gj-RGd" firstAttribute="trailing" secondItem="Jc0-6G-14K" secondAttribute="trailing" constant="16" id="gsD-dt-UHe"/>
213+
<constraint firstItem="DtM-Mo-ib8" firstAttribute="leading" secondItem="Bh0-gj-RGd" secondAttribute="leading" constant="20" id="s2E-XM-6AZ"/>
214+
<constraint firstItem="Jc0-6G-14K" firstAttribute="leading" secondItem="Bh0-gj-RGd" secondAttribute="leading" constant="20" id="vgP-ls-FrA"/>
215+
</constraints>
198216
<viewLayoutGuide key="safeArea" id="Bh0-gj-RGd"/>
199217
</view>
200218
</viewController>
201219
<placeholder placeholderIdentifier="IBFirstResponder" id="66m-s4-m0S" userLabel="First Responder" sceneMemberID="firstResponder"/>
202220
</objects>
203-
<point key="canvasLocation" x="898.55072463768124" y="132.88043478260872"/>
221+
<point key="canvasLocation" x="898.39999999999998" y="132.68365817091455"/>
204222
</scene>
205223
</scenes>
206224
</document>

textToCode/textToCode/SpeechProcessor.swift

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,7 @@ class SpeechProcessor {
4242
let lowerCaseResult: String = result.lowercased();
4343
let resultArr1 = lowerCaseResult.components(separatedBy: " ");
4444
var resultArr = resultArr1.prefix(resultArr1.count - 1);
45-
/* SCRIPT::
46-
big test phrase:
47-
48-
49-
new private class dog stop
50-
new private method hello returns string stop
51-
return hello how are you stop
52-
new public method count legs returns integer stop
53-
new private variable integer i equals seven plus five stop
54-
while i less than 4 stop
55-
i plus plus stop
56-
print i stop
57-
if i equals 4 stop
58-
i equals two stop
59-
print i stop
60-
else if i equals 5 stop
61-
i minus minus stop
62-
print i stop
63-
else
64-
print i stop
65-
return i plus 5 stop
66-
67-
//Other test phrases:
68-
69-
new public variable boolean bye stop
70-
new private method good bye returns integer stop
71-
while bye equals true stop
72-
return bye stop
73-
new public variable string hi there equals seven stop
74-
75-
if bye equals true stop
76-
bye equals false stop
77-
else stop
78-
bye equals true stop
79-
80-
*/
45+
8146
for wordIndex in 0..<resultArr.count{
8247

8348
//NEW CLASS: eg: "new private class dog stop "

textToCode/textToCode/ViewController.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ class ViewController: UIViewController, SFSpeechRecognizerDelegate {
7575
timerLabel.text = "\(timeLeft)";
7676
if(timeLeft < 1){
7777
self.audioEngine.stop()
78+
self.timerLabel.text = "55";
7879
self.timer?.invalidate();
7980
self.recognitionRequest?.endAudio()
8081
self.recordButton.isEnabled = true
81-
self.recordButton.setTitle("Start Recording", for: .normal)
82+
self.recordButton.setTitle(" Start ", for: .normal)
8283
}
8384
}
8485

@@ -131,15 +132,16 @@ class ViewController: UIViewController, SFSpeechRecognizerDelegate {
131132
@IBAction func recordPressed(_ sender: UIButton) {
132133
if audioEngine.isRunning {
133134
timer?.invalidate();
135+
timerLabel.text = "55";
134136
audioEngine.stop()
135137
recognitionRequest?.endAudio()
136138
recordButton.isEnabled = true
137-
recordButton.setTitle("Start Recording", for: .normal)
139+
recordButton.setTitle(" Start ", for: .normal)
138140
} else {
139141
timeLeft = 56;
140142
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(tick(_:)), userInfo: nil, repeats: true)
141143
startRecording()
142-
recordButton.setTitle("Stop Recording", for: .normal)
144+
recordButton.setTitle(" Stop ", for: .normal)
143145
}
144146
}
145147

@@ -176,11 +178,12 @@ class ViewController: UIViewController, SFSpeechRecognizerDelegate {
176178

177179
if((result?.bestTranscription.segments[(result?.bestTranscription.segments.count)! - 2].substring.lowercased().contains("stop"))!){
178180
self.audioEngine.stop()
181+
self.timerLabel.text = "55";
179182
self.timer?.invalidate();
180183
inputNode.removeTap(onBus: 0)
181184
self.recognitionRequest?.endAudio()
182185
self.recordButton.isEnabled = true
183-
self.recordButton.setTitle("Start Recording", for: .normal)
186+
self.recordButton.setTitle(" Start ", for: .normal)
184187
}else{
185188

186189
//Only pasrse the new segments
@@ -205,6 +208,7 @@ class ViewController: UIViewController, SFSpeechRecognizerDelegate {
205208
if error != nil || isFinal {
206209
self.timer?.invalidate();
207210
self.audioEngine.stop()
211+
self.timerLabel.text = "55";
208212
inputNode.removeTap(onBus: 0)
209213
self.recognitionRequest = nil
210214
self.recognitionTask = nil

0 commit comments

Comments
 (0)