Latest / CyberSecurity Summary / Voice Application Development for Android
Transcript
- 0:00Speaker 1: You know, it's wild how second nature it's become to
- 0:03Speaker 1: just talk to our devices. Hey, Google, set a timer, Siri,
- 0:07Speaker 1: what's the weather? We barely think about it.
- 0:09Speaker 2: Yeah, it really feels like something we just take for
- 0:11Speaker 2: granted now, But.
- 0:12Speaker 1: Pull back for a second. How does that actually happen?
- 0:14Speaker 1: How does your phone hear you, understand what you want,
- 0:17Speaker 1: and then you know, do something.
- 0:19Speaker 2: It does feel a bit like a magic trick, doesn't it.
- 0:22Speaker 2: But behind that simple interaction is this whole layered world
- 0:25Speaker 2: of technology.
- 0:27Speaker 1: It's quite complex, actually, and that's exactly the world we're
- 0:30Speaker 1: diving into today. We're taking a deep dive into how
- 0:33Speaker 1: you build these voice based applications, specifically thinking about Android devices.
- 0:38Speaker 2: Okay, and our guide for this exploration is fascinating. It
- 0:41Speaker 2: is a detailed technical guide published back in twenty thirteen.
- 0:45Speaker 1: Twenty thirteen, so a bit of a snapshot from that
- 0:47Speaker 1: era exactly.
- 0:48Speaker 2: It gives us a really interesting look at the tools
- 0:50Speaker 2: and approaches developers we're using them, leveraging Google's own capabilities
- 0:54Speaker 2: and also some open source software.
- 0:56Speaker 1: Right, So, our mission in this deep dive is to
- 0:59Speaker 1: kind of cut through the complexity. We want to unpack
- 1:02Speaker 1: the core concepts the essential building blocks.
- 1:04Speaker 2: Fundamental, Yeah, the.
- 1:05Speaker 1: Fundamentals, and show you the journey developers took to create
- 1:09Speaker 1: apps you could talk to all without you needing to
- 1:12Speaker 1: pour over the original technical manual yourself.
- 1:15Speaker 2: Sounds good.
- 1:16Speaker 1: We'll start with the absolute basics, speaking and listening and
- 1:19Speaker 1: build up from there, maybe getting into complex conversations and
- 1:23Speaker 1: even early virtual assistance.
- 1:25Speaker 2: Okay, let's unpack this starting at the very beginning, seems right.
- 1:29Speaker 2: Before a device can respond or have any kind of conversation,
- 1:32Speaker 2: it first has to be able to speak. And here right.
- 1:36Speaker 1: The fundamental capabilities Android provides for this are text to
- 1:39Speaker 1: speech TTS and automated speech recognition or ASR.
- 1:45Speaker 2: And thinking about why these are important, Well, it opens
- 1:48Speaker 2: up so many possibilities. Imagine your hands are full like
- 1:51Speaker 2: you're driving and need directions.
- 1:53Speaker 1: Oh yeah, it's simple then or and.
- 1:55Speaker 2: This is crucial for accessibility. Think about someone with a
- 1:58Speaker 2: visual impairment using a green reader that's TTS or ASR
- 2:03Speaker 2: helping someone communicate if they have difficulty speaking, much like
- 2:07Speaker 2: Stephen Hawking used speech synthesis technology.
- 2:10Speaker 1: They're really foundational tools. Okay, let's start with TTS text
- 2:14Speaker 1: to speech. Simply put, it turns written text into spoken audio.
- 2:19Speaker 2: Right, and the technology works in stages. First, it needs
- 2:22Speaker 2: to understand the text itself, things like you know how
- 2:25Speaker 2: to pronounce words that look similar but sound different based
- 2:28Speaker 2: on context.
- 2:28Speaker 1: Like reads versus read just exactly.
- 2:31Speaker 2: Or converting numbers and abbreviations into full words. The cool
- 2:35Speaker 2: part for developers often is the system handles a lot
- 2:38Speaker 2: of this linguistic complexity. You don't always have to get
- 2:41Speaker 2: into the weeds.
- 2:41Speaker 1: Okay, So it understands the text, then it has to
- 2:43Speaker 1: generate the actual sound exactly.
- 2:46Speaker 2: A common approach, especially around the time this book was written,
- 2:49Speaker 2: was something called concatenative synthesis.
- 2:51Speaker 1: Concatenative synthesis okay, okay.
- 2:53Speaker 2: Think of it like building a sentence by stitching together
- 2:55Speaker 2: tiny prerecorded pieces of speech. These could be sounds, syllables, words,
- 3:00Speaker 2: even short phrases.
- 3:01Speaker 1: Ah like digital lego bricks for voice.
- 3:04Speaker 2: Kind of algorithms select the right pieces and join them smoothly,
- 3:07Speaker 2: trying to mimic natural rhythm and intonation. When it's done well,
- 3:12Speaker 2: it can sound remarkably natural.
- 3:14Speaker 1: It's kind of amazing how they make those pieces fit together.
- 3:17Speaker 1: But wait, if they're stitching together pre recorded bits, why
- 3:20Speaker 1: not just record a human voice actor saying everything the
- 3:22Speaker 1: app might need to say.
- 3:24Speaker 2: That's a great point, and sometimes apps do use professional
- 3:27Speaker 2: voice actors, you know, for specific tromps where quality and
- 3:31Speaker 2: consistency are paramount.
- 3:33Speaker 1: Like a standard greeting or instruction exactly.
- 3:36Speaker 2: But TTS becomes absolutely essential when the text is dynamic,
- 3:40Speaker 2: when you can't possibly pre record everything it might need
- 3:43Speaker 2: to say.
- 3:43Speaker 1: Ah, right, like reading out a text message.
- 3:45Speaker 2: You just got, or a news headline that just updated, or.
- 3:48Speaker 1: Someone's name from your contact.
- 3:49Speaker 2: List Precisely, you just can't anticipate every single phraser name.
- 3:53Speaker 2: So while the quality might sometimes be a trade off
- 3:55Speaker 2: compared to say, a perfectly recorded voice, linets offers that
- 4:00Speaker 2: vital flexibility for dynamic content.
- 4:02Speaker 1: And Android has had this built in for ages. Right, how
- 4:06Speaker 1: do developers actually hook into it?
- 4:07Speaker 2: Yeah, the capability has been there since Android one point six.
- 4:12Speaker 2: Believe or not, developers use the framework provided. A key
- 4:16Speaker 2: step is making sure the necessary language data is actually
- 4:19Speaker 2: on the user's.
- 4:20Speaker 1: Device the voice itself.
- 4:22Speaker 2: Yeah, the voice files the rules for that language. The
- 4:25Speaker 2: system lets developers check for this using something called an intent,
- 4:28Speaker 2: and even prompt the user to install it if it's missing.
- 4:31Speaker 1: Okay.
- 4:32Speaker 2: The book suggests using a common software design pattern, a singleton,
- 4:36Speaker 2: basically ensuring only one instance of the TTS engine is created.
- 4:39Speaker 2: This helps manage resources efficiently smart and the examples in
- 4:42Speaker 2: the book show how you might use this to say,
- 4:45Speaker 2: read back text the user piped in, or maybe read
- 4:47Speaker 2: text loaded from a file. You can specify the language too,
- 4:50Speaker 2: like English or even regional variation.
- 4:52Speaker 1: Okay, so that's how the device speaks. Now the other
- 4:54Speaker 1: side hearing us automated Speech recognition ASR. This is turning
- 5:00Speaker 1: our spoken words into text.
- 5:02Speaker 2: Right, and like TTS, it involves steps. First, the device
- 5:06Speaker 2: needs to capture the sound from the microphone and process it.
- 5:09Speaker 2: Think of it as cleaning up.
- 5:10Speaker 1: The audio, getting rid of background noise.
- 5:11Speaker 2: Yeah, removing noise maybe echo, and just preparing it digitally
- 5:16Speaker 2: for analysis.
- 5:17Speaker 1: Then comes the recognition part itself. Yeah, breaking down the
- 5:19Speaker 1: audio into.
- 5:22Speaker 2: What sounds basically yeah, into tiny segments phones the basic
- 5:27Speaker 2: sounds of the language, and then it tries to match them.
- 5:30Speaker 1: Wow.
- 5:31Speaker 2: This is where powerful statistical models come into play. These
- 5:34Speaker 2: models are trained on massive amounts of recorded speech, learning
- 5:38Speaker 2: how different sounds are typically pronounced in different context by
- 5:41Speaker 2: different people.
- 5:41Speaker 1: Wow.
- 5:42Speaker 2: Okay, they build what's called an acoustic model. It's essentially
- 5:45Speaker 2: a statistical map of how sounds relate to words.
- 5:48Speaker 1: But words can sound exactly alike you mentioned read and
- 5:51Speaker 1: read or two and two. How does it know the difference?
- 5:55Speaker 2: Ah, good question. That's where another statistical model helps, the
- 5:58Speaker 2: language model.
- 5:59Speaker 1: Language model.
- 6:00Speaker 2: This one understands the probability of words appearing together in sequence.
- 6:04Speaker 2: It knows that after I went, the word two is
- 6:08Speaker 2: far far more likely than two.
- 6:10Speaker 1: Right context exactly.
- 6:12Speaker 2: The language model provides that crucial context to help resolve
- 6:15Speaker 2: those ambiguities.
- 6:16Speaker 1: And the result isn't always just one single interpretation, is
- 6:19Speaker 1: it like? It's not always certain?
- 6:22Speaker 2: No, definitely not. Typically, the ASR system gives you back
- 6:26Speaker 2: a list of possible results, ranked by how confident it
- 6:29Speaker 2: is in each one. A list, yeah, it's often called
- 6:32Speaker 2: an end best list. Each possibility comes with a confidence score,
- 6:36Speaker 2: usually from zero to one. A score near one means
- 6:39Speaker 2: the system is pretty.
- 6:40Speaker 1: Sure it got it right, and that's useful for the developer.
- 6:43Speaker 2: Incredibly valuable. They can just pick the top result. If
- 6:46Speaker 2: the confidence is high, or if it's lower, or if
- 6:49Speaker 2: the top one doesn't make sense in context, they can
- 6:51Speaker 2: look at the others in the list. Or maybe even
- 6:54Speaker 2: use the confidence score to decide HM I better ask
- 6:56Speaker 2: the user to confirm this.
- 6:58Speaker 1: This capability has also been around on end for a
- 7:00Speaker 1: while since version two point one. Often when you tap
- 7:03Speaker 1: the little microphone icon on the keyboard.
- 7:05Speaker 2: Yes exactly, and developers have flexibility here too. You can
- 7:08Speaker 2: use a simple built in tool and intent that handles
- 7:11Speaker 2: the speak now, prompt and feedback automatically, super easy, quick
- 7:15Speaker 2: and dirty, pretty much. Or if you want more control
- 7:18Speaker 2: over the look and feel the user interface, you could
- 7:22Speaker 2: use a more advanced component a speech recognizer instance. This
- 7:25Speaker 2: lets you manage the UI yourself and react to specific
- 7:29Speaker 2: recognition events like when the user starts or stops speaking.
- 7:32Speaker 1: More control, more work typically yeah.
- 7:35Speaker 2: The book again suggests using a library approach here, like
- 7:38Speaker 2: an ASRLB, just to keep the code organized and reusable.
- 7:42Speaker 1: And you mentioned language models. Can you tell the system
- 7:45Speaker 1: what kind of speech to expect, like am I dictating
- 7:48Speaker 1: an email or just barking a search query?
- 7:51Speaker 2: Exactly? You can specify different language models. There's one design
- 7:54Speaker 2: for free form dictation like long sentences, and another optimized
- 7:58Speaker 2: for shorter phrases like web search queries.
- 8:00Speaker 1: Ah.
- 8:01Speaker 2: The book does note though, that even with these models,
- 8:03Speaker 2: the input can still be quite open ended, so the
- 8:06Speaker 2: developer might need to do more processing afterwards to figure
- 8:09Speaker 2: out the specific command or meaning.
- 8:11Speaker 1: Oh and because these systems often connect to cloud services
- 8:14Speaker 1: for the heavy lifting.
- 8:15Speaker 2: Right, the recognition part. Yeah, the app usually needs permission
- 8:19Speaker 2: to access the Internet, and you need to handle potential
- 8:22Speaker 2: errors like no speech detected or no match found or
- 8:27Speaker 2: maybe a network problem.
- 8:29Speaker 1: Got it. So we've got the building blocks. The device
- 8:32Speaker 1: can speak TTS, and it can listen and turn speech
- 8:36Speaker 1: into text ASR even giving us a list of possibilities
- 8:40Speaker 1: with confidence scores. How do we actually put those together
- 8:43Speaker 1: to build simple interactions?
- 8:45Speaker 2: That's the next logical step, right, moving from just hearing
- 8:48Speaker 2: or speaking to creating a basic back and forth. Think
- 8:51Speaker 2: about those early voice actions.
- 8:53Speaker 1: Like on Google Now back in the.
- 8:54Speaker 2: Day, exactly telling your phone call mom or go to
- 8:57Speaker 2: Wikipedia dot org. These are structured commands, simple cause and.
- 9:01Speaker 1: Effect, and they're built just by combining those core TTS
- 9:04Speaker 1: and ASR capabilities we just talked about.
- 9:06Speaker 2: Pretty much the book provides them straightforward examples. One is
- 9:09Speaker 2: an app called voice Search.
- 9:10Speaker 1: It just takes whatever you say, listens using ASR right.
- 9:13Speaker 2: Grabs the top result from that end best list the
- 9:16Speaker 2: one with the highest confidence it seems it's right, and
- 9:18Speaker 2: immediately plugs it into a standard Android web search intent.
- 9:22Speaker 2: Boom search results appear very.
- 9:24Speaker 1: Simple, okay, but that immediately brings up a potential problem
- 9:27Speaker 1: which you hinted at. What if the ASR got it
- 9:30Speaker 1: wrong exactly? This seems particularly tricky in another example app.
- 9:34Speaker 1: The book mentions voice Launch, which tries to launch an
- 9:37Speaker 1: installed application based on what the user says. Right, what
- 9:41Speaker 1: if you don't say the exact app name, like maybe
- 9:44Speaker 1: you say music player, but the app is actually called
- 9:47Speaker 1: play Music.
- 9:48Speaker 2: This is where the idea of similarity measures comes in.
- 9:50Speaker 2: It's a crucial concept. The app needs a way to
- 9:54Speaker 2: compare what the user said to the actual names of
- 9:57Speaker 2: the apps installed on the device to find the best
- 10:00Speaker 2: to match, even if it's not identical.
- 10:02Speaker 1: How does it do that? Just check if the letters
- 10:04Speaker 1: are similar.
- 10:05Speaker 2: That's part of an orthographic similarity looking at the spelling.
- 10:08Speaker 2: But crucially, it can also look at phonetic similarity.
- 10:11Speaker 1: How words sound alike?
- 10:12Speaker 2: Yes, so it could figure out that, I don't know,
- 10:15Speaker 2: photos and photos probably refer to the same thing, even
- 10:19Speaker 2: if the spelling's different.
- 10:20Speaker 1: Okay, that's clever.
- 10:21Speaker 2: The book mentions using algorithms like soundex for this phonetic comparison,
- 10:26Speaker 2: although it notes the specific implementation they included was primarily
- 10:29Speaker 2: tuned for English. The key thing is normalizing the input first,
- 10:34Speaker 2: like her moving spaces, making everything lower case before you do.
- 10:38Speaker 2: The comparison makes sense.
- 10:39Speaker 1: Okay, So even with similarity measures, ASR isn't perfect. That
- 10:43Speaker 1: potential for error means you often need to double check
- 10:47Speaker 1: with the user right confirm things absolutely.
- 10:50Speaker 2: Confirmation is vital for robust interaction. The book includes a
- 10:53Speaker 2: simple example building on that Voicer chap. After recognizing something
- 10:58Speaker 2: like pizza places right, yeah, might use TTS to ask
- 11:01Speaker 2: did you say pizza places? And then it uses ASR again,
- 11:04Speaker 2: but this time listening specifically for a simple.
- 11:06Speaker 1: Yes or no uh, constraining the expected input exactly.
- 11:11Speaker 2: It's a basic but really important step, especially when you're
- 11:13Speaker 2: dealing with single critical pieces of data before taking an action.
- 11:17Speaker 1: So we can make the device speak, listen, perform. These
- 11:20Speaker 1: simple command action pairs handle some ambiguity with similarity, and
- 11:24Speaker 1: even ask for basic yes no confirmation. But these interactions
- 11:29Speaker 1: still feel quite rigid. You know, you have to say
- 11:31Speaker 1: things in a very specific way or is just one
- 11:34Speaker 1: command at a time. How do you make the conversation
- 11:36Speaker 1: more flexible, like guide the user through collecting multiple pieces
- 11:40Speaker 1: of information?
- 11:41Speaker 2: Okay, yeah, that takes us into the realm of more
- 11:44Speaker 2: structured conversations, often called form filling.
- 11:47Speaker 1: Dialogue form filling like on a website.
- 11:49Speaker 2: Exactly the same idea. The goal is to gather several
- 11:52Speaker 2: distinct pieces of information from the user, one by one,
- 11:56Speaker 2: but doing it through voice instead of textboxes and dropdowns.
- 11:58Speaker 1: Okay, So, like booking a flow, it might ask what
- 12:01Speaker 1: city are you flying from? Then once you answer, what
- 12:04Speaker 1: is your destination exactly?
- 12:05Speaker 2: And then maybe what date do you want to travel.
- 12:07Speaker 2: To manage this, you need a system. You need a
- 12:10Speaker 2: way to define the pieces of information you need. Think
- 12:12Speaker 2: of these as slots to be.
- 12:14Speaker 1: Filled like fields on a form.
- 12:15Speaker 2: Precisely, and you need an algorithm, some logic that knows
- 12:19Speaker 2: how to navigate the conversation to collect the info for
- 12:22Speaker 2: EID slot in some sensible order.
- 12:24Speaker 1: The book points to something called VoiceXML as a kind
- 12:27Speaker 1: of model for this.
- 12:28Speaker 2: Yeah. VoiceXML is or was, a W three C standard
- 12:32Speaker 2: for defining these kinds of voice dialogues often used in
- 12:35Speaker 2: call center systems. It uses concepts like forms, which contain
- 12:39Speaker 2: fields or slots. Each field has a prompt, which is
- 12:43Speaker 2: what the system asks the user.
- 12:44Speaker 1: What is your destination right?
- 12:46Speaker 2: And optionally, fields can have grammars associated with them, which
- 12:50Speaker 2: constrain or help interpret what the user can say in response.
- 12:53Speaker 1: So for a destination field, the grammar might only accept
- 12:56Speaker 1: city names.
- 12:57Speaker 2: Potentially yes and VoiceXML uses a concept called the form
- 13:01Speaker 2: interpretation algorithm or FIA. It's basically the logic engine that
- 13:05Speaker 2: steps through the form, asking for one piece of required
- 13:08Speaker 2: information at a time until all the necessary slots are filled.
- 13:12Speaker 2: The book uses a simplified subset of these ideas specifically
- 13:15Speaker 2: for Android development, and.
- 13:16Speaker 1: There's a specific library in the book to help build this.
- 13:19Speaker 2: Yes a library called form filip containing classes to represent
- 13:23Speaker 2: these forms and fields. It works by parsing XML files
- 13:27Speaker 2: that the developer writes. These XML files define the structure
- 13:30Speaker 2: of the conversation, what questions to ask, in what order,
- 13:34Speaker 2: which fields are needed, so.
- 13:35Speaker 1: The conversation logic is separate from the main app code exactly.
- 13:39Speaker 2: It uses standard Android tools like XML pull parser handled
- 13:42Speaker 2: via another helper library, xml lib to read these definitions.
- 13:46Speaker 2: Then a key piece called the dialogue interpreter class steps
- 13:50Speaker 2: through this structure, triggering the right TTS prompt and listening
- 13:53Speaker 2: for ASR responses to fill each field.
- 13:55Speaker 1: Does it handle background tasks like parsing might take time?
- 13:59Speaker 2: Good point. It's designed to do the potentially slow work
- 14:02Speaker 2: like parsing the XML or waiting for ASR in the
- 14:05Speaker 2: background using Android's acing task, so the main app remains responsive.
- 14:09Speaker 2: That separation of concerns is really nice.
- 14:11Speaker 1: A great example used in the book is the music
- 14:13Speaker 1: Brain app. What does that do?
- 14:15Speaker 2: Right? The music Brain demo app uses this form filling library.
- 14:18Speaker 2: It guides the user through a voice dialogue asking for
- 14:21Speaker 2: details like maybe a word that appears in an album
- 14:23Speaker 2: title or a start an end.
- 14:25Speaker 1: Date range, using that form structure.
- 14:27Speaker 2: Exactly once, it collects all the pieces of information needs
- 14:30Speaker 2: by filling the slots in its form, and use that
- 14:33Speaker 2: collected information to query the music Brain's web service, which
- 14:37Speaker 2: is a big online music database.
- 14:39Speaker 1: Ah. So it's combining the voice interface with external data a.
- 14:43Speaker 2: Mashup, precisely. It shows how you can take destruction data
- 14:47Speaker 2: gathered via voice and uses to interact with online services
- 14:51Speaker 2: retrieve information. Process it may be filter or sort the
- 14:55Speaker 2: results like sorting albums by release date using helper classes,
- 14:59Speaker 2: and then present that back to the user, perhaps speaking
- 15:01Speaker 2: the results or showing them on screen.
- 15:03Speaker 1: Okay, so form filling lets us manage these multi step
- 15:06Speaker 1: conversations to get structured data like album name and date range.
- 15:10Speaker 1: But you mentioned that the ASR input within each step
- 15:13Speaker 1: was still somewhat open ended in these basic examples. How
- 15:17Speaker 1: do we make the app understand more than just the
- 15:19Speaker 1: words the user says? How do we get it to
- 15:22Speaker 1: understand the meaning behind the words?
- 15:24Speaker 2: Right? That's a critical step towards more intelligent interaction, and
- 15:27Speaker 2: that's where grammars come in, leading us into the field
- 15:29Speaker 2: of natural language understanding or NLU.
- 15:32Speaker 1: Grammars and NLU Okay.
- 15:34Speaker 2: Grammars are tools designed specifically to help the application interpret
- 15:38Speaker 2: more complex user inputs. They help extract not just the
- 15:41Speaker 2: sequence of words, but the underlying meaning and specific structured
- 15:45Speaker 2: pieces of information.
- 15:47Speaker 1: So going beyond just recognizing show me flights to London
- 15:51Speaker 1: as a sequence of words.
- 15:52Speaker 2: So understanding that the user's intent is to see flights
- 15:56Speaker 2: and the destination parameter is London.
- 15:58Speaker 1: Got it? How do you create these grammars?
- 16:01Speaker 2: The book discusses two main approaches. First, there are handcrafted.
- 16:05Speaker 1: Grammars written manually by developers.
- 16:07Speaker 2: Exactly, you write them yourself, often in an XML format
- 16:10Speaker 2: like SRGS Speech Recognition Grammar Specification, though the book uses
- 16:15Speaker 2: its own simplified XML format. You define the structure of
- 16:18Speaker 2: acceptable phrases using rules, items within rules, alternatives, optional parts,
- 16:24Speaker 2: and links between different rules.
- 16:25Speaker 1: Can you give an example for that flight query?
- 16:28Speaker 2: Sure, you might have a top level rule like rule
- 16:31Speaker 2: ID fine flight. Inside that you might have an item
- 16:34Speaker 2: for the phrase show flights or fine flights. Then maybe
- 16:38Speaker 2: an optional item repeat zero one for the word two,
- 16:42Speaker 2: and then crucially a reference to another rule like ruler
- 16:45Speaker 2: ref u r F hashtag city which defines all the
- 16:48Speaker 2: valid city names.
- 16:49Speaker 1: And the hashtag city rule would list London, Paris, New
- 16:52Speaker 1: York right.
- 16:53Speaker 2: And within those rules you can use special semantic tags.
- 16:56Speaker 2: So next to the item London in the city rule,
- 16:59Speaker 2: you might have a tag like tag out lhr tag.
- 17:02Speaker 2: This tells the system if the user says London, don't
- 17:05Speaker 2: just return the word London, return the airport code lhr AH.
- 17:09Speaker 1: Extracting structured data directly based on the grammar match. That's powerful,
- 17:14Speaker 1: very powerful.
- 17:15Speaker 2: But as you can imagine writing these grammars to cover
- 17:18Speaker 2: all the different ways a user might phrase.
- 17:19Speaker 1: Something flights to London, show me London flights. I want
- 17:22Speaker 1: to flight to London exactly.
- 17:23Speaker 2: Designing handcrafted grammars for spontaneous, unpredictable speech is incredibly hard
- 17:28Speaker 2: and very time consuming. That's the big challenge.
- 17:30Speaker 1: So what's the alternative.
- 17:32Speaker 2: That's where the second type comes in. Statistical grammars, or
- 17:36Speaker 2: more broadly, statistical NLU.
- 17:37Speaker 1: Models learn from data.
- 17:39Speaker 2: Yes, these aren't written by hand. They're trained on vast
- 17:43Speaker 2: amounts of real world language data using machine learning techniques, and.
- 17:47Speaker 1: The advantage is they can be much more flexible handle
- 17:50Speaker 1: variations you didn't explicitly code for.
- 17:52Speaker 2: That's the key benefit. Because they work based on probabilities
- 17:56Speaker 2: and patterns learn from how people actually speak, they can
- 17:59Speaker 2: often handle more or irregular wording, synonyms, even slightly ungrammatical
- 18:04Speaker 2: inputs that would break a strict handcrafted grammar.
- 18:07Speaker 1: What's the downside?
- 18:09Speaker 2: The main one is they require huge data sets to
- 18:11Speaker 2: train effectively, and access to these trained models often comes
- 18:14Speaker 2: via cloud services. The book mentions a service from a
- 18:17Speaker 2: company called Maluba as an example of a real world
- 18:20Speaker 2: statistical NLU system available around that time.
- 18:22Speaker 1: And that kind of system tries to identify the core
- 18:25Speaker 1: intention and the relevant details the entities.
- 18:27Speaker 2: Precisely, you give it a phrase like what's the weather
- 18:31Speaker 2: in Belfast for tomorrow, and a statistical NLU system could
- 18:34Speaker 2: analyze it and return something structured like categories whether action is,
- 18:39Speaker 2: check status, and the entities are location, billfast, and date tomorrow,
- 18:43Speaker 2: maybe even resolving tomorrow to the actual calendar date. It's
- 18:46Speaker 2: focused on extracting that core meaning, often regardless of the
- 18:50Speaker 2: exact sentence structure used.
- 18:52Speaker 1: Does the book include a library to help developers work
- 18:55Speaker 1: with these different grammar types.
- 18:56Speaker 2: It does. An NLU lib. It contains classes for handelling
- 19:00Speaker 2: those handcrafted grammars, parsing the XML definitions into Java objects,
- 19:04Speaker 2: inverting the rules into patterns, often using regular expressions behind
- 19:07Speaker 2: the scenes, and then using Java's matching tools to check
- 19:10Speaker 2: user input against these patterns. It also extracts the semantic
- 19:14Speaker 2: information based on those tags we talked.
- 19:16Speaker 1: About, and for the statistical ones.
- 19:18Speaker 2: The library also incling code demonstrating how to connect to
- 19:21Speaker 2: external statistical NLU services like that mlluda API, sending the
- 19:26Speaker 2: user's text and parsing the structured semantic result that comes back, assuming,
- 19:30Speaker 2: of course, the developer has API access.
- 19:32Speaker 1: And is there a demo app to play with this?
- 19:35Speaker 2: Yes, a grammar test app. It's quite useful. It lets
- 19:38Speaker 2: you input text, either typing it or using the results
- 19:41Speaker 2: from ASR, and then test that input against either a
- 19:44Speaker 2: handcrafted grammar file you provide or by sending it off
- 19:48Speaker 2: to the statistical.
- 19:48Speaker 1: Service so you can see the difference exactly.
- 19:51Speaker 2: It shows you whether the input is considered valid according
- 19:54Speaker 2: to the grammar and more importantly, what semantic information or
- 19:58Speaker 2: structured representation some extracts. It's a clear way to see
- 20:02Speaker 2: the different capabilities and outputs of the two approaches to
- 20:05Speaker 2: understanding language.
- 20:06Speaker 1: Okay, this is really building up. We've gone from basic
- 20:08Speaker 1: speaking and listening to simple commands, structured form filling, and
- 20:12Speaker 1: now understanding meaning with grammars and NLU. How do we
- 20:16Speaker 1: make these voice apps even more robust and user friendly,
- 20:20Speaker 1: maybe for a wider audience or in different situations.
- 20:23Speaker 2: Well, two key aspects the book covers next are multi
- 20:26Speaker 2: linguality and multimodality.
- 20:28Speaker 1: Multi linguality supporting different languages seems obvious, but important.
- 20:32Speaker 2: Absolutely essential if you want your app to reach a
- 20:34Speaker 2: global audience. It means being able to use TTS and
- 20:37Speaker 2: ASR and languages other than.
- 20:39Speaker 1: Just the default How do developers handle that.
- 20:42Speaker 2: They specify the languages using standard codes like ISO six
- 20:46Speaker 2: three nine tosh one codes N for English as for
- 20:49Speaker 2: Spanish and so on. The Android system provides ways again
- 20:52Speaker 2: using intents to check which languages are actually supported or
- 20:55Speaker 2: installed on the user's specific device.
- 20:57Speaker 1: Because not all devices might have all languages pre installed, right, and.
- 21:02Speaker 2: This ties directly into the broader concept of localization in
- 21:05Speaker 2: Android development, you know, providing different text strings, images layouts,
- 21:09Speaker 2: and resource folders like resvalues for Spanish users versus Ree's
- 21:13Speaker 2: values and for English users. It's about adapting the whole
- 21:16Speaker 2: app experience. The book has a very simple silly parrot
- 21:20Speaker 2: app just to show switching TTSASR language.
- 21:22Speaker 1: Okay, so that's multiple languages. What about multimodality sounds complex?
- 21:26Speaker 2: It just means combining voice interaction with the traditional graphical
- 21:29Speaker 2: user interface, the GUI, the buttons and screens we're used
- 21:32Speaker 2: to tapping.
- 21:32Speaker 1: On ah, voice and touch working together. Why do that?
- 21:36Speaker 2: Because sometimes tapping is just easier or faster than speaking
- 21:39Speaker 2: for certain inputs, or users might want visual feedback confirming
- 21:45Speaker 2: what the system understood, or maybe they start by voice
- 21:48Speaker 2: and when finished by touch or vice versa. The idea
- 21:51Speaker 2: is to create a seamless link, a link between what
- 21:54Speaker 2: between the fields of information we were talking about in
- 21:56Speaker 2: form filling dialogues and the visual elements on the screen
- 22:00Speaker 2: like drop down lists, spinners and android lists. You can
- 22:03Speaker 2: scroll list views, radio buttons, checkboxes, text entry fields, edit text.
- 22:07Speaker 1: Okay, so how does that work in practice?
- 22:10Speaker 2: Imagine you have a field in your voice dialogue for say, urgency,
- 22:14Speaker 2: with options low, medium, high. You might also have radio
- 22:17Speaker 2: buttons on the screen for the same options. Right, If
- 22:20Speaker 2: the user says medium urgency, the app not only fills
- 22:23Speaker 2: that voice field internally, but it also automatically checks the
- 22:26Speaker 2: meeting radio button on.
- 22:27Speaker 1: The screen ah synchronization exactly.
- 22:30Speaker 2: And conversely, if the user taps the high radio button
- 22:33Speaker 2: on the screen, the app knows that the urgency information
- 22:36Speaker 2: has been provided, so the voice dialogue system shouldn't ask
- 22:38Speaker 2: for it orally anymore. The state is shared.
- 22:41Speaker 1: That sounds really useful, but potentially complex to manage.
- 22:44Speaker 2: It requires careful design. Grammars become important here too, to
- 22:48Speaker 2: ensure that the voice input for a specific field actually
- 22:52Speaker 2: matches one of the valid options available in the corresponding
- 22:56Speaker 2: GUI element, Like the items.
- 22:58Speaker 1: And a drop down list, and the book provides hell
- 23:00Speaker 1: for this too.
- 23:00Speaker 2: Another library, Yes, building on the form filling one, a
- 23:03Speaker 2: multimodal form FILLIP. It extends the basic form library by
- 23:07Speaker 2: adding grammar checking within the dialogue flow, so it only
- 23:11Speaker 2: accepts voice input that actually matches the grammar defined for
- 23:14Speaker 2: the current field. And crucially, it includes methods like oral
- 23:18Speaker 2: to gee and GI toral specifically designed to synchronize the
- 23:21Speaker 2: state between the internal voice feels and the visual GUI elements.
- 23:24Speaker 1: Is there an example app for this?
- 23:26Speaker 2: They use a mock send message app as a demonstration.
- 23:28Speaker 2: It lets the user provide details for sending a message
- 23:31Speaker 2: recipient urgency, maybe the message body itself, either by speaking the.
- 23:35Speaker 1: Information following the form filling prompts.
- 23:37Speaker 2: Right, or by interacting directly with the GeOI elements on
- 23:41Speaker 2: the screen, like picking a contact from a list or
- 23:43Speaker 2: tapping a radio button for urgency. The app keeps track
- 23:47Speaker 2: of the information consistently, regardless of whether it came via
- 23:50Speaker 2: voice or touch. It really highlights how voice and touch
- 23:53Speaker 2: don't have to be separate, isolated interaction modes. They can
- 23:57Speaker 2: compliment each other within the same task.
- 23:59Speaker 1: Okay, this is quite a journey We've layered on all
- 24:01Speaker 1: these capabilities speaking, listening, simple commands, handling, ambiguity, multistep forms,
- 24:10Speaker 1: really understanding language with Grammars in NLU, adding flexibility with
- 24:14Speaker 1: multiple languages, and combining voice with the screen through multimodality.
- 24:18Speaker 1: What happens when you take all these pieces and integrate
- 24:21Speaker 1: them into one coherent system, Well, that's when.
- 24:23Speaker 2: You get into the realm of virtual Personal assistance.
- 24:25Speaker 1: Vpas AH the serious, the Google Assistance, the Alexis of
- 24:29Speaker 1: the world exactly.
- 24:30Speaker 2: These are the conversational agents we're much more familiar with today.
- 24:34Speaker 2: They really represent the culmination of all these underlying technologies
- 24:37Speaker 2: we've been discussing, designed to understand potentially complex requests and
- 24:41Speaker 2: perform a whole range of tasks.
- 24:43Speaker 1: And the fundamental challenge for a VPA trying to bring
- 24:46Speaker 1: everything together must be accurately figuring out the user's intention
- 24:50Speaker 1: from whatever they happen to say, however they say it.
- 24:53Speaker 2: That's the core of it. And as we saw when
- 24:55Speaker 2: discussing Grammars in NLU, you can approach this understanding in
- 24:59Speaker 2: different ways. You might try to classify the user's input
- 25:02Speaker 2: using statistical methods trained on lots of.
- 25:04Speaker 1: Data, which is good for more open ended questions or requests.
- 25:07Speaker 2: Right, or you might use more structured grammars for specific commands,
- 25:11Speaker 2: extracting the core intent in any relevant details or parameters.
- 25:15Speaker 2: Often modern systems use a hybrid approach.
- 25:18Speaker 1: And once the intention is hopefully understood, the VPA needs
- 25:21Speaker 1: more logic. Right, it needs a system to decide what
- 25:24Speaker 1: to do next.
- 25:25Speaker 2: Definitely, it needs dialogue management. Based on the understood intent
- 25:29Speaker 2: and the current state of the conversation, the dialogue manager
- 25:32Speaker 2: decides the next action. Does it need to ask a
- 25:35Speaker 2: clarifying question, Does it have enough information to perform the task?
- 25:38Speaker 2: Does it need to access some data?
- 25:40Speaker 1: And then it needs to generate a response.
- 25:42Speaker 2: Yes, response generation figuring out what to say back to
- 25:46Speaker 2: the user via PTS or what information to display on
- 25:49Speaker 2: the screen, or what action to actually perform on the
- 25:52Speaker 2: device or via web service.
- 25:54Speaker 1: This whole idea of conversational AI has a long history,
- 25:57Speaker 1: doesn't it even before smartphone?
- 25:59Speaker 2: Oh yeah, it goes way back. The book even mentions
- 26:01Speaker 2: early chatbots like Eliza from the nineteen sixties, but for
- 26:04Speaker 2: building more sophisticated vpas around the time the book was written.
- 26:08Speaker 2: It focuses on using a specific platform called Pandora Bots.
- 26:11Speaker 1: Pandora Bots, what's that?
- 26:13Speaker 2: It's a platform still reunt today actually for creating and
- 26:16Speaker 2: hosting conversational agents or chatbots uses a language called AML.
- 26:21Speaker 2: AML Artificial Intelligence Markup language is based on XML, and
- 26:25Speaker 2: it lets you define the bot's conversational behavior using categories.
- 26:29Speaker 2: Each category has a pattern which is basically.
- 26:31Speaker 1: What the user might say a potential input phrase.
- 26:33Speaker 2: Right, and a template which defines how the bots should respond.
- 26:37Speaker 2: You can use wild cards like in the patterns to
- 26:40Speaker 2: make them more flexible, matching multiple variations of user input,
- 26:44Speaker 2: and there are special tags like srey that let you
- 26:47Speaker 2: redirect from one pattern to another, helping to handle synonyms
- 26:51Speaker 2: or rephrase requests without duplicating logic.
- 26:53Speaker 1: What happens if the user says something that doesn't match
- 26:56Speaker 1: any pattern?
- 26:57Speaker 2: Good question? AML has the concept of an ultimate default category,
- 27:02Speaker 2: a fallback pattern that matches anything else, usually triggering a
- 27:05Speaker 2: response like sorry, I didn't understand that or could you rephrase?
- 27:10Speaker 2: It's crucial for making the bot seem less brittle.
- 27:12Speaker 1: Okay, So the core conversation logic matching input patterns to
- 27:16Speaker 1: output templates runs on the Pandora Bots platform. How does
- 27:19Speaker 1: that connect to doing things on the Android device.
- 27:22Speaker 2: This is where a really interesting feature mentioned in the
- 27:24Speaker 2: book comes in, specifically designed for mobile vpas. It's the
- 27:28Speaker 2: UB tag oh ob out a band. It's a special
- 27:30Speaker 2: tag that the AML developer can embed within the box
- 27:33Speaker 2: response template alongside the text the bot is supposed to say,
- 27:37Speaker 2: how does that work? So the box template might have
- 27:39Speaker 2: the text okay, I'll search the web for that for you,
- 27:42Speaker 2: but hitting within the same AML template, there could also
- 27:44Speaker 2: be an UB tag containing a command like search query
- 27:47Speaker 2: the user asked for search okay, the Android app communicates
- 27:51Speaker 2: with the Pandora bot online. It sends the user's transcribed
- 27:54Speaker 2: speech from ASR. The Pandora bot finds the matching pattern
- 27:58Speaker 2: and sends back the AML template response. The Android app
- 28:01Speaker 2: then parses this response. It takes the regular tax part okay,
- 28:05Speaker 2: I'll search and sends it to the TTS engine to
- 28:07Speaker 2: be spoken. But it also looks for any ubtags. If
- 28:11Speaker 2: it find one, like search, it intercepts that command and
- 28:14Speaker 2: executes the corresponding action on the device, in this case
- 28:17Speaker 2: launching a web search with a specified query wow.
- 28:20Speaker 1: So the conversation, logic and knowledge stays centralized on the
- 28:23Speaker 1: Pandora bot server define an AML, but the actual device
- 28:26Speaker 1: actions searching, launching apps, making calls, opening URLs are triggered
- 28:30Speaker 1: locally on the Android device by these hidden commands embedded
- 28:34Speaker 1: in the bot's response exactly.
- 28:36Speaker 2: It's a clever way to decouple the conversational intelligence from
- 28:39Speaker 2: the specific device functionalities. The book provides a vp lib
- 28:44Speaker 2: library to handle this communication, connecting to a specific Pandora
- 28:47Speaker 2: bot online using its bodhead sending the ASR input, parsing
- 28:52Speaker 2: the XML response from Pandora bots, looking for the spoken
- 28:55Speaker 2: part often marked by a FAT tag, and checking for ubtags,
- 28:59Speaker 2: and then running the course wonding functions on the device
- 29:01Speaker 2: based on those tags. The book did note a limitation
- 29:04Speaker 2: at the time that the gender of the TTS voice
- 29:06Speaker 2: couldn't be controlled programmatically, which might affect the perceived persona
- 29:10Speaker 2: of the bot.
- 29:10Speaker 1: Does the book include sample vpas built using this Pandora
- 29:14Speaker 1: bots approach?
- 29:14Speaker 2: It does. It described three Jack, Derek and Stacy. Jack
- 29:18Speaker 2: is based on a well known general purpose amail bot
- 29:21Speaker 2: called Alice, designed for broad open ended conversation. Derek, on
- 29:25Speaker 2: the other hand, is presented as a specialized bot. It
- 29:27Speaker 2: trains specifically on a particular knowledge domain. The example uses
- 29:31Speaker 2: FAQs about type two diabetes. This highlights how you can
- 29:34Speaker 2: encode expert or domain specific knowledge using these AMMEL patterns
- 29:38Speaker 2: and templates.
- 29:38Speaker 1: So one generalist, one specialist, and Stacy.
- 29:41Speaker 2: Stacy is basically Jack the general conversational bot, but enhanced
- 29:47Speaker 2: with that oub tag functionality, so Stacey can not only chat,
- 29:52Speaker 2: but can also actually control device functions like searching online
- 29:56Speaker 2: or launching apps based on understanding those embedded commands within
- 30:00Speaker 2: the conversation flow.
- 30:00Speaker 1: That really brings it all together. If you look back
- 30:03Speaker 1: at how the book illustrates the overall VPA structure, you know,
- 30:08Speaker 1: starting with ASR capturing the audio, then spoken language understanding
- 30:12Speaker 1: whether that's NLU, grammars or AML pattern matching to figure.
- 30:16Speaker 2: Out the intent right the understanding part.
- 30:18Speaker 1: Then dialogue management deciding the next step, response generation formulating
- 30:22Speaker 1: the output, and finally TTS speaking the response.
- 30:25Speaker 2: All while potentially connecting to external data sources, knowledge bases,
- 30:29Speaker 2: and triggering those device actions via things like the ouptech.
- 30:32Speaker 1: You can really see how all those individual building blocks
- 30:35Speaker 1: we discuss, TTS, ASR, forms, grammars, multimodality fit together into
- 30:40Speaker 1: that complete VPA system.
- 30:42Speaker 2: It is the full picture. Now show how you assemble
- 30:43Speaker 2: these components to create those conversational agency.
- 30:46Speaker 1: And that really brings our deep dove to a close,
- 30:48Speaker 1: doesn't it. We've journeyed all the way from the absolute fundamentals,
- 30:52Speaker 1: the device's ability to speak using TTS and listen using ASR.
- 30:57Speaker 2: The core building blocks, through.
- 30:59Speaker 1: Building those first simple command interactions, bringing in ideas like
- 31:03Speaker 1: similarity measures and confirmation.
- 31:05Speaker 2: Making them a bit more robust, and.
- 31:06Speaker 1: Structuring more complex multi turn conversations using form filling dialogues,
- 31:11Speaker 1: managing the flow to gather.
- 31:12Speaker 2: Information, getting that structured data, then.
- 31:14Speaker 1: Diving into how to understand user input more deeply, moving
- 31:18Speaker 1: beyond words to meaning using both handcrafted and statistical grammars via.
- 31:23Speaker 2: NLU, extracting intent and entities, and.
- 31:27Speaker 1: Then adding layers of flexibility through multilinguality supporting different languages
- 31:31Speaker 1: and multimodality, seamlessly combining voice with graphical interfaces.
- 31:36Speaker 2: Making the interaction richer and more adaptable.
- 31:38Speaker 1: And finally we saw how all these technologies converge in
- 31:41Speaker 1: the architecture of virtual personal assistance, using platforms like Pandora
- 31:46Speaker 1: bots with AML and leveraging clever techniques like that OOB
- 31:50Speaker 1: tag to bridge the gap between conversation and actually doing
- 31:54Speaker 1: things on the device.
- 31:56Speaker 2: Absolutely, This deep dive, even though it's rooted in a
- 31:59Speaker 2: technical guide from over a decade ago, now really gives
- 32:03Speaker 2: you a solid conceptual shortcut. It helps you understand the
- 32:07Speaker 2: core challenges and the fundamental building blogs involved in bringing
- 32:10Speaker 2: voice interaction to life on a device.
- 32:13Speaker 1: Yeah, it lays out the pieces really clearly and considering
- 32:16Speaker 1: all these elements together, from breaking down sounds and words
- 32:19Speaker 1: to understanding complex intent, managing dialogue flow over multiple turns,
- 32:23Speaker 1: generating responses, and having the ability to trigger pretty much
- 32:26Speaker 1: any device function or connect to any web service. It
- 32:30Speaker 1: really opens up your imagination, doesn't it, to the kind
- 32:32Speaker 1: of truly personalized voice applications you could potentially create.
- 32:36Speaker 2: Right, It makes you think beyond the general purpose assistance
- 32:39Speaker 2: we mostly use today. What if a voice assistant wasn't
- 32:41Speaker 2: just generic? What if it was deeply, deeply specialized.
- 32:45Speaker 1: Yeah, Like, imagine a VPA that understands the incredibly specific vocabulary,
- 32:51Speaker 1: the jargon, the unique needs of your particular hobby or
- 32:54Speaker 1: your specific job, maybe using a custom built grammar or
- 32:58Speaker 1: a finely tuned n LU model, and it could instantly
- 33:01Speaker 1: connect you to niche online resources or internal databases that
- 33:05Speaker 1: a general assistant wouldn't even know existed, Or.
- 33:08Speaker 2: Think about something more personal, maybe an assistant that reads
- 33:11Speaker 2: you recipes, but it uses curated audio samples to sound
- 33:14Speaker 2: like a comforting, familiar voice, maybe even your grandmother's voice.
- 33:18Speaker 2: If you had the recordings and it lets you navigate
- 33:21Speaker 2: the cooking steps completely hands free, using just simple voice
- 33:24Speaker 2: commands tailored to that specific.
- 33:26Speaker 1: Task, that would be amazing. It makes you wonder what
- 33:29Speaker 1: kinds of unique, genuinely helpful or even just wonderfully quirky,
- 33:33Speaker 1: and specific voice interfaces are still waiting to be built,
- 33:36Speaker 1: especially when you start combining these foundational technologies tts ASR
- 33:41Speaker 1: NLU dialogue management, device control in new and unexpected ways.
- 33:45Speaker 2: Exactly what's the potential beyond the mainstream assistance we interact
- 33:48Speaker 2: with now? It definitely leaves you with something to think about.