1
00:00:00,350 --> 00:00:05,880
Hire everyone in this material we're going to go ahead and we're going to create a new app called Map

2
00:00:05,940 --> 00:00:07,320
speech app.

3
00:00:07,350 --> 00:00:12,240
So before that we need to make sure that our SDK components are actually updated.

4
00:00:12,420 --> 00:00:17,460
So here click on configure and then click on STK manager.

5
00:00:17,480 --> 00:00:20,730
So now you can see that is the case manager is open for us.

6
00:00:20,810 --> 00:00:27,920
Make sure that you have actually downloaded the Android 7 point 1.1 target or Android 7.0 or Android

7
00:00:27,920 --> 00:00:36,940
6 0 a marshmallow here or above and then make sure to actually click on these STK tools pop here.

8
00:00:37,780 --> 00:00:43,470
So here make sure to actually have this Android SDK tools installed.

9
00:00:43,510 --> 00:00:45,360
We have this android emulator.

10
00:00:45,370 --> 00:00:47,260
You can see that the update is available.

11
00:00:47,260 --> 00:00:53,160
So I'm going to update it here and we can see you can see that the Android platform tool.

12
00:00:53,170 --> 00:00:55,510
Here is updates are available here.

13
00:00:55,510 --> 00:00:56,990
Make sure to update this one too.

14
00:00:57,100 --> 00:01:00,820
So let me actually first show you all these components.

15
00:01:00,820 --> 00:01:02,530
So here let's scroll down.

16
00:01:02,530 --> 00:01:05,520
Here you can see this one here support repository.

17
00:01:05,800 --> 00:01:11,360
And you can see that the Google repository is actually that you have you can see this update is available.

18
00:01:11,560 --> 00:01:14,090
Make sure to also update this one too.

19
00:01:14,470 --> 00:01:17,800
In other words let's actually check this support repository here.

20
00:01:17,800 --> 00:01:19,140
This package.

21
00:01:19,450 --> 00:01:24,370
And now let's scroll to the top and you can see that this one Google Play services here.

22
00:01:24,460 --> 00:01:27,270
We can also update this package here.

23
00:01:27,310 --> 00:01:31,720
Check this check box and Android as is the case platform tools.

24
00:01:31,720 --> 00:01:33,600
Make sure to also check the street check box.

25
00:01:33,610 --> 00:01:35,410
And this one and emulator.

26
00:01:35,770 --> 00:01:40,370
So here let's just click on apply here.

27
00:01:41,460 --> 00:01:48,030
And it says the following components will be installed Android platform tools version this one twenty

28
00:01:48,150 --> 00:01:50,210
five point zero point six.

29
00:01:50,370 --> 00:01:56,460
And all these other components Android emulator Google Play services and Google repository these are

30
00:01:56,460 --> 00:02:02,340
the necessary components that we need in order to actually create this application that we're about

31
00:02:02,340 --> 00:02:03,410
to create.

32
00:02:03,420 --> 00:02:04,930
So let's click on OK.

33
00:02:05,280 --> 00:02:10,260
And now it's going to start actually updating these components for us.

34
00:02:10,260 --> 00:02:16,880
So I'm going to post the video and then I'm going to actually just again start recording the video after

35
00:02:16,890 --> 00:02:18,960
these components are updated.

36
00:02:19,380 --> 00:02:23,520
So now that those are necessary components are actually updated.

37
00:02:23,550 --> 00:02:26,710
Let's create an android studio project.

38
00:02:27,030 --> 00:02:32,900
So the application name is going to be app 79 app 79.

39
00:02:32,910 --> 00:02:35,710
You can name it whatever you want but I'm going to actually name it in this way.

40
00:02:35,720 --> 00:02:36,460
17:9.

41
00:02:36,810 --> 00:02:41,980
And then here you can specify the company domain to package name and a projected location.

42
00:02:42,210 --> 00:02:51,450
So just click next and here choose a 16 Android 4.1 jellybean for phone and tablet just click next and

43
00:02:51,450 --> 00:02:55,170
here choose any activity next.

44
00:02:55,170 --> 00:03:00,050
So here you can specify the activity and make sure that this checkbox is actually checked to generate

45
00:03:00,060 --> 00:03:00,910
lay out file.

46
00:03:01,060 --> 00:03:06,480
Lay out name is activity and underline main and make sure that this checkbox here is also checked backwards

47
00:03:06,480 --> 00:03:10,010
compatibility ABC1 but just click Finish.

48
00:03:10,020 --> 00:03:11,620
So let's wait a little bit here.

49
00:03:11,700 --> 00:03:17,630
So now that the project is created Let's go to our outfight activity and element of the exam.

50
00:03:17,630 --> 00:03:21,410
So here make sure to actually open these and review here.

51
00:03:21,690 --> 00:03:27,120
And if you don't have this android view you can't just click on these two little triangles here you

52
00:03:27,120 --> 00:03:30,740
can see this dropdown menu and then you can actually click on Android.

53
00:03:30,810 --> 00:03:31,260
OK.

54
00:03:31,410 --> 00:03:35,370
So let's open the rest folder and then open the layout folder.

55
00:03:35,610 --> 00:03:39,160
Double click on this activity underline minute exam here.

56
00:03:39,180 --> 00:03:44,160
So now let's double click on that in order to make this area wider so let's select this hello world

57
00:03:44,170 --> 00:03:47,300
text view and then present it on your keyboard.

58
00:03:47,730 --> 00:03:53,730
And here I want to switch to the take a stab at instead of constrained to lay out I'm going to change

59
00:03:53,730 --> 00:03:55,300
it to relatively fast.

60
00:03:55,410 --> 00:04:00,850
So just sitting here relatively out and you can see that the ending here is also relatively out.

61
00:04:00,900 --> 00:04:02,790
So let's go back to the design tab.

62
00:04:03,060 --> 00:04:09,810
Now here inside is pallet section let's click on layouts and let's strike a linearly old vertical here

63
00:04:10,110 --> 00:04:14,550
into this relatively out and put it here at the center of this relatively flat.

64
00:04:14,730 --> 00:04:15,380
OK.

65
00:04:15,810 --> 00:04:18,330
So you can see that this linearly or it's vertical here.

66
00:04:18,340 --> 00:04:24,180
It's lay out which is much apparent its length height is you can't see much apparent and the orientation

67
00:04:24,210 --> 00:04:25,520
is worth the color.

68
00:04:25,770 --> 00:04:29,080
Let's say that I text you into this linearly R20 cold.

69
00:04:29,130 --> 00:04:33,570
So just going all here inside is Pallot section and selectees takes.

70
00:04:33,630 --> 00:04:37,490
And just drag it here into these linearly out vertical.

71
00:04:37,490 --> 00:04:44,650
Here let's say this takes the takes of this it takes to be at the center of this takes you so selectees

72
00:04:44,660 --> 00:04:48,770
takes view here and lets you inside this property section.

73
00:04:48,770 --> 00:04:54,440
Let's go to the view all properties and let's search for the gravity attribute here.

74
00:04:54,470 --> 00:04:58,250
So search for gravity and let's actually find that.

75
00:04:58,260 --> 00:04:59,040
Here's what it is.

76
00:04:59,040 --> 00:05:02,380
This is actually the gravity attribute that we actually make a wider.

77
00:05:02,520 --> 00:05:07,500
So open this gravity here by just clicking on this little triangle here.

78
00:05:07,860 --> 00:05:12,280
And check this checkbox that says Center horizontal.

79
00:05:12,510 --> 00:05:17,250
Now we can see that the text of this text view is under center at the center of the state's view.

80
00:05:17,250 --> 00:05:18,090
Right.

81
00:05:18,090 --> 00:05:26,670
So let's actually here scroll down here and let's click on view fewer properties and specify an idea

82
00:05:26,670 --> 00:05:27,470
for the states.

83
00:05:27,480 --> 00:05:33,230
The idea is going to be the value and then present until General keyboard.

84
00:05:33,480 --> 00:05:34,370
So that's it.

85
00:05:34,380 --> 00:05:37,830
Let's go to our main activity class here.

86
00:05:37,830 --> 00:05:44,010
So here first of all we want to actually work with the speech recognition library with a speech recognition

87
00:05:44,010 --> 00:05:45,200
framework actually.

88
00:05:45,480 --> 00:05:49,410
So inside this class we need to create a constant.

89
00:05:49,410 --> 00:05:51,690
Actually that is called a request.

90
00:05:51,690 --> 00:06:00,510
So just they've been here private static final INT and the name of this constant here is going to be

91
00:06:00,570 --> 00:06:05,180
speech requests so make sure that the name of this constant is capitalized.

92
00:06:05,170 --> 00:06:11,230
Here is actually the convention the name of your constants always should be capitalized speech underline

93
00:06:11,410 --> 00:06:12,570
request.

94
00:06:12,950 --> 00:06:13,870
Right.

95
00:06:13,950 --> 00:06:19,170
And here put an assignment operator and assign the value number 10 to this constant.

96
00:06:19,170 --> 00:06:21,120
This is the request right.

97
00:06:21,150 --> 00:06:24,580
It doesn't matter what value you assign to this constant.

98
00:06:24,580 --> 00:06:28,660
The value the number that you assign to this constant must be unique.

99
00:06:28,920 --> 00:06:31,470
So I assign the value number 10 to this constant.

100
00:06:32,010 --> 00:06:39,060
So here first of all let me tell you that this application must be tested on a real Android device.

101
00:06:39,060 --> 00:06:44,850
You cannot test this app on an emulator because the emulator does not support speech recognition.

102
00:06:44,850 --> 00:06:52,230
So make sure that you have actually connected your Andretti voice to your computer and hear first inside

103
00:06:52,230 --> 00:06:53,740
this uncreate method.

104
00:06:53,760 --> 00:07:00,990
We must make sure that the user's device does actually support speech speech recognition.

105
00:07:00,990 --> 00:07:05,350
So in order to do that we need to actually access the package manager so to step in here.

106
00:07:05,460 --> 00:07:10,600
Package Manager and the name of this variable is going to be package manager assignment operator.

107
00:07:10,950 --> 00:07:12,890
And here I can say this.

108
00:07:12,900 --> 00:07:15,800
So this refers to an instance of type main activity.

109
00:07:16,020 --> 00:07:19,430
So notice that when ever that we actually run the application.

110
00:07:19,680 --> 00:07:24,570
And whenever the main activity is called and the main activity or the activity on Allemagne at this

111
00:07:24,580 --> 00:07:29,960
time it is actually on the screen an instance of the main activity class is going to be created.

112
00:07:29,970 --> 00:07:32,540
So this refers to that instance.

113
00:07:32,670 --> 00:07:35,690
So does that get package manager.

114
00:07:35,730 --> 00:07:43,590
So in this way we can access the package manager here and then let's create an new line here and here

115
00:07:43,590 --> 00:07:45,970
we need to access the information of the device.

116
00:07:46,140 --> 00:07:49,740
So we need to create a value of type list here.

117
00:07:49,860 --> 00:07:56,220
So notice that the list is actually an interface so just put up a pair of angle brackets and instead

118
00:07:56,220 --> 00:08:01,140
of angle brackets we need to specify that data type of the objects that are going to be inside this

119
00:08:01,140 --> 00:08:06,130
list which is going to be resolved in full resolve in full.

120
00:08:06,670 --> 00:08:10,760
And let me now let me show you the Android documentation.

121
00:08:10,910 --> 00:08:12,950
So here it is the android documentation.

122
00:08:12,950 --> 00:08:21,420
So inside the search bar here search for results in full right and it says and read AP eyes and do it

123
00:08:21,450 --> 00:08:26,060
that content that PM that result in for just click on this one here.

124
00:08:26,600 --> 00:08:29,060
So it says probably class resolve in 40.

125
00:08:29,060 --> 00:08:34,920
So this is actually a class that extends the object class and implements the parsable interface.

126
00:08:35,180 --> 00:08:41,150
So look at this description here it is information that is returned from resolving an intent against

127
00:08:41,300 --> 00:08:42,980
an intent filter.

128
00:08:43,040 --> 00:08:50,200
This partially corresponds to information collected from the and manifest that XML so let's scroll down

129
00:08:50,200 --> 00:08:50,420
here.

130
00:08:50,430 --> 00:08:55,840
Look at the summary here and here you can see all these actually the values here.

131
00:08:55,840 --> 00:08:56,450
Right.

132
00:08:56,740 --> 00:08:58,920
So let's go back to android studio.

133
00:08:58,930 --> 00:09:03,940
You can if you want to you can actually read these with this documentation here but I'm going to go

134
00:09:03,940 --> 00:09:07,310
back to android studio and here I can see a list.

135
00:09:07,390 --> 00:09:15,590
So the name of this valuable it's going to be a list of information assignment operator and now I'm

136
00:09:15,590 --> 00:09:21,320
going to access the package manager rowdier but that I created here so I can say package manager dot

137
00:09:21,680 --> 00:09:24,490
Querrey intent activities.

138
00:09:24,530 --> 00:09:25,310
So select this one.

139
00:09:25,310 --> 00:09:28,230
He had that query into the activities.

140
00:09:28,250 --> 00:09:34,900
So now let's go back to android documentation here and had inside the search bar here just typing here.

141
00:09:34,900 --> 00:09:38,660
Package Manager package manager.

142
00:09:39,170 --> 00:09:40,480
And here he can see this one here.

143
00:09:40,490 --> 00:09:45,680
And with that content that PM the package manager just click on this one here.

144
00:09:46,020 --> 00:09:48,020
So this is our package manager class.

145
00:09:48,030 --> 00:09:49,840
This is actually an abstract class.

146
00:09:49,860 --> 00:09:50,730
Right.

147
00:09:50,730 --> 00:09:52,950
So here let's look at this documentation.

148
00:09:52,950 --> 00:09:59,850
This description it says class for retrieving various kinds of information related to the application

149
00:09:59,850 --> 00:10:03,270
packages that are currently installed on the device.

150
00:10:03,330 --> 00:10:06,440
You can find this class pro-death package manager.

151
00:10:06,960 --> 00:10:10,340
So let's search for the query intent activities.

152
00:10:10,510 --> 00:10:14,920
So here if you are using a match you can't just hold down the comment and then press on that.

153
00:10:14,940 --> 00:10:21,150
If on your keyboard or if you are using a Windows machine just to hold down the control on your keyboard

154
00:10:21,210 --> 00:10:24,950
and then press on that if on your keyboard and here inside the search.

155
00:10:24,960 --> 00:10:33,500
But again it says for Querrey intent activities so this is the method that you're looking for.

156
00:10:33,500 --> 00:10:40,250
So if it says retrieve all activities that can be performed for the given intent.

157
00:10:40,520 --> 00:10:41,550
Right.

158
00:10:41,690 --> 00:10:49,370
So why we are calling this method because we want to make sure that we can actually access the speech

159
00:10:49,370 --> 00:10:51,550
recognition capability of the device.

160
00:10:51,860 --> 00:10:58,700
So let's go back to android studio here and let's let me show you first that this if it accepts two

161
00:10:58,700 --> 00:11:03,150
arguments the first one is of the intent and the second argument is actually of the integer.

162
00:11:03,170 --> 00:11:04,720
And it is flaks.

163
00:11:04,760 --> 00:11:06,110
So let's go back to our studio.

164
00:11:06,110 --> 00:11:09,120
So we need to pass these two arguments to this method here.

165
00:11:09,470 --> 00:11:13,630
So for the intent here let me create a new line and just step in here.

166
00:11:13,630 --> 00:11:20,180
New intent because we must pass a value of intent here to dismiss it for the first argument.

167
00:11:20,300 --> 00:11:26,420
So new intent and here instead Apprentice's of this intent we are actually calling the constructor of

168
00:11:26,420 --> 00:11:27,170
this intent here.

169
00:11:27,170 --> 00:11:27,910
Right.

170
00:11:27,980 --> 00:11:32,280
So in that Apprentice's I can say recognize their intent.

171
00:11:32,300 --> 00:11:34,250
So just they can recognize their intent.

172
00:11:34,250 --> 00:11:37,650
So let's let me actually show you the and regimentation.

173
00:11:37,760 --> 00:11:44,210
So here inside this search spirals so just referred to this recognizer intent here recognizer intent

174
00:11:44,630 --> 00:11:47,110
and Royte that speech that recognize that intent.

175
00:11:47,120 --> 00:11:48,050
Just click on it.

176
00:11:48,290 --> 00:11:53,380
So here you can see that this is actually a class that extends the object class.

177
00:11:53,420 --> 00:11:54,370
Right.

178
00:11:54,380 --> 00:12:00,570
So now let's look at this description it says constants for supporting speech recognition for thought

179
00:12:00,790 --> 00:12:01,960
and intent.

180
00:12:01,970 --> 00:12:08,650
This is very important constants for supporting speech recognition for starting an intent.

181
00:12:08,650 --> 00:12:15,490
So this means that we must start an intent in order to access this speech recognition.

182
00:12:15,500 --> 00:12:19,840
So let's let's go back to Andrew's studio and he had to step in here.

183
00:12:19,910 --> 00:12:24,090
Dot action recognize speech.

184
00:12:24,110 --> 00:12:30,620
So now let's go back to android city or to other documentation actually and here let's search for action

185
00:12:31,880 --> 00:12:33,920
underline recognize speech.

186
00:12:33,920 --> 00:12:42,320
So we get this one here it says starts an activity that will prompt the user for a speech and send it

187
00:12:42,350 --> 00:12:44,510
through a speech recognizer.

188
00:12:44,510 --> 00:12:45,630
Right.

189
00:12:45,740 --> 00:12:48,650
So it's going to start an activity for us this month.

190
00:12:48,680 --> 00:12:50,700
So let's go back to android studio.

191
00:12:50,720 --> 00:12:55,370
So here we want to actually start the actually recognize speech intent.

192
00:12:55,520 --> 00:12:56,050
OK.

193
00:12:56,210 --> 00:12:59,020
And here we are checking for that condition.

194
00:12:59,060 --> 00:13:04,160
So here you can see that this Smurfette quirky Internet activities needs the second arguments or just

195
00:13:04,160 --> 00:13:06,670
put a comma here which is going to be the flex.

196
00:13:06,680 --> 00:13:13,050
So for the Flex argument just passed the value zero here and at the end of our statement we must pass.

197
00:13:13,160 --> 00:13:14,870
We must put a semicolon here.

198
00:13:14,900 --> 00:13:16,100
Right.

199
00:13:16,100 --> 00:13:17,890
So here we are getting the information.

200
00:13:17,900 --> 00:13:19,320
The list of information actually.

201
00:13:19,340 --> 00:13:22,540
And here this variable holds those information.

202
00:13:22,880 --> 00:13:29,790
So now we want to make sure that the users the voice does actually support speech recognition.

203
00:13:29,810 --> 00:13:40,430
So here I can create an if statement so if list of information if a list of information that size is

204
00:13:40,460 --> 00:13:42,760
actually greater than zero.

205
00:13:43,180 --> 00:13:46,930
OK I just need to open and close this if they've been by using these curly braces.

206
00:13:46,970 --> 00:13:52,530
This means that if the size of this list is actually greater than zero.

207
00:13:52,550 --> 00:13:56,690
This means that the user's device does support speech recognition.

208
00:13:56,690 --> 00:14:02,280
In that case you are 100 and 50 percent sure that it is true.

209
00:14:02,450 --> 00:14:06,600
And we can actually create a host message that make text.

210
00:14:06,590 --> 00:14:10,260
So first we need to pass the context in activity that this on.

211
00:14:10,400 --> 00:14:24,310
The message is going to be your device your device doest support speech recognition speech recognition

212
00:14:25,390 --> 00:14:26,030
right.

213
00:14:26,230 --> 00:14:31,110
And then here put a actually an up and exclamation mark here.

214
00:14:31,450 --> 00:14:32,890
So let's put a comma here.

215
00:14:32,890 --> 00:14:38,860
And finally even if we just need to specify the duration of this message which is going to be the short

216
00:14:39,750 --> 00:14:42,920
lived short.

217
00:14:43,020 --> 00:14:46,630
And finally we need to call this show him Fifth this toast object.

218
00:14:46,800 --> 00:14:50,890
So let me create a new line here so that he can see what's going on here exactly.

219
00:14:52,390 --> 00:14:53,940
So this is our total message.

220
00:14:54,220 --> 00:15:00,760
So what happens if the user's device does not support this speech or speech recognition.

221
00:15:00,760 --> 00:15:05,830
In that case we are going to create an L statements or else I just need to open and close this statement

222
00:15:06,160 --> 00:15:07,460
by using these curly braces.

223
00:15:07,480 --> 00:15:11,900
Let's copy and paste this TOSed message here and put it here.

224
00:15:11,920 --> 00:15:19,900
Paste it here inside this block and here for the message I can see that your device does not support

225
00:15:19,960 --> 00:15:23,230
does not support speech recognition.

226
00:15:23,350 --> 00:15:30,010
So let's run the app on an emulator here because I want to show you that on the emulator here just to

227
00:15:30,010 --> 00:15:31,590
take this one and then click on OK.

228
00:15:31,600 --> 00:15:36,120
So here it says your device does support speech recognition.

229
00:15:36,110 --> 00:15:40,730
But yes it's going to actually show us dismiss this year but it's not actually exactly true.

230
00:15:40,930 --> 00:15:46,500
Because in order to test this feature we must use our own real Android device.

231
00:15:46,600 --> 00:15:47,090
OK.

232
00:15:47,530 --> 00:15:49,160
So that's it in the next story.

233
00:15:49,180 --> 00:15:51,740
We're going to continue building this application.

234
00:15:52,000 --> 00:15:53,050
Thank you very much for watching.

235
00:15:53,050 --> 00:15:57,430
If you have any questions about the concepts that I taught you in this lesson please post the discussion

236
00:15:57,430 --> 00:16:00,160
in the course and then I do my best to answer all of your questions.

