Natural Language Processing Lab guide
Guide to NLP Lab and its codes
We were given the problems for the first part of the natural language processing lab work as,
1
2
3
4
5
6
7
8
9
10
11
Lab problems
1. Implementation of Text Tokenization and Stop Word Removal Using Python and NLTK
2. Implementation of Word Analysis and Word Generation in Natural Language Processing
3. Implementation of Word Sense Disambiguation (WSD) Using Python
4. Implementation of Stemming Using the NLTK Toolkit
5. Implementation of Part-of-Speech (POS) Tagging and Word POS Identification Using NLTK
6. Implementation of Morphological Analysis, N-Gram Generation, and N-Gram Smoothing Using NLTK
7. POS Tag Ambiguity Resolution Using Transition and Emission Probabilities in NLP
8. Implementation of Grapheme-to-Phoneme (G2P) Conversion
9. Implementation of Text-to-Speech (TTS) for Converting Text into Audio
10. Implementation of Automatic Speech Recognition (ASR) for Converting Audio into Text
The texts used across the tasks are,
1
2
"JKKNIU stands as a dedicated center for higher education, honoring the profound cultural and literary legacy of Bangladesh's national poet."
"Jatiya Kabi Kazi Nazrul Islam University (JKKNIU) is a premier public university in Trishal, Mymensingh, established in 2006."
before we work with the code here are the libraries that are needed.
1
pip install nltk gTTS pydub SpeechRecognition
So we have to use python for the tasks and we have to use NLTK library for the tasks, and write the codes as well.
1. Tokenization + Stop word removal
The first task we are given is as follows,
- Write a Python Program to perform following tasks on text “JKKNIU stands as a dedicated center for higher education, honoring the profound cultural and literary legacy of Bangladesh’s national poet.”
- Tokenization
- Stop word Removal
And the code for this is,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.corpus import stopwords
nltk.download('punkt')
nltk.download('punkt_tab')
nltk.download('stopwords')
text = "JKKNIU stands as a dedicated center for higher education, honoring the profound cultural and literary legacy of Bangladesh's national poet."
tokens = word_tokenize(text)
print("Tokens:", tokens)
print("Sentences:", sent_tokenize(text))
stop = set(stopwords.words('english'))
filtered = [w for w in tokens if w.lower() not in stop and w.isalnum()]
print("After stop word removal:", filtered)
here we have to use the punkt and punkt_tab for tokenization and stopwords for stop word removal.
2. Word Analysis and Word Generation
In the second problem we are asked to
- Write Python Program for,
- Word Analysis
- Word Generation.
so the code is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import nltk
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.corpus import stopwords, wordnet
from nltk import FreqDist
from nltk.stem import PorterStemmer, WordNetLemmatizer
nltk.download('punkt')
nltk.download('punkt_tab')
nltk.download('wordnet')
text = "JKKNIU stands as a dedicated center for higher education, honoring the profound cultural and literary legacy of Bangladesh's national poet."
tokens = word_tokenize(text)
# a) Word analysis: frequency, length, root and affix
words = [w.lower() for w in tokens if w.isalpha()]
print("Total:", len(words), "| Unique:", len(set(words)))
print("Most common:", FreqDist(words).most_common(3))
ps, wl = PorterStemmer(), WordNetLemmatizer()
for w in ['honoring', 'dedicated', 'stands']:
stem = ps.stem(w)
print(w, "| length:", len(w), "| stem:", stem,
"| lemma:", wl.lemmatize(w, 'v'), "| suffix:", w[len(stem):])
# b) Word generation: root + suffixes, keep only real words
root = 'play'
suffixes = ['', 's', 'ed', 'ing', 'er', 'ers', 'ful', 'ly', 'able']
generated = [root + s for s in suffixes if wordnet.synsets(root + s)]
print("Generated words:", generated)
3. Word Sense Disambiguation
we have to show 5 sentences with ambigious words and use nltk to remove ambiguity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import nltk
from nltk.tokenize import word_tokenize
from nltk.wsd import lesk
nltk.download('punkt')
nltk.download('punkt_tab')
samples = [('bank', "I deposited money in the bank"),
('bank', "We sat on the bank of the river"),
('bat', "He hit the ball with a bat"),
('bass', "He plays the bass guitar in a band"),
('plant', "The plant produces electricity for the city"),
('spring', "Water flows from the spring in the hill")]
for word, sent in samples:
sense = lesk(word_tokenize(sent), word)
print(word, "->", sense, ":", sense.definition() if sense else "no sense found")
4. Stemming Using the NLTK Toolkit
stemming is a process of removing affixes from words to get to the root form of the word. Lemmatization is a more refined process of stemming. It takes into account the context of the word and returns the dictionary form of the word, which is also known as the lemma.
1
2
3
4
5
6
7
8
9
10
11
import nltk
from nltk.stem import PorterStemmer, LancasterStemmer, SnowballStemmer
nltk.download('punkt')
nltk.download('punkt_tab')
ws = ['running', 'flies', 'happily', 'studies', 'generously', 'connected']
porter, lancaster, snowball = PorterStemmer(), LancasterStemmer(), SnowballStemmer('english')
print(f"{'word':12}{'porter':10}{'lancaster':12}{'snowball'}")
for w in ws:
print(f"{w:12}{porter.stem(w):10}{lancaster.stem(w):12}{snowball.stem(w)}")
5. POS Tagging of words using NLTK Library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import nltk
from nltk import pos_tag
nltk.download('punkt')
nltk.download('punkt_tab')
nltk.download('averaged_perceptron_tagger')
nltk.download('averaged_perceptron_tagger_eng')
wlist = ['run', 'beautiful', 'quickly', 'university', 'she',
'and', 'under', 'eat', 'happy', 'book', 'the', 'they']
tags = dict(pos_tag(wlist))
print(tags)
w = input("Enter a word: ").lower()
print(w, "->", tags.get(w) or pos_tag([w])[0][1])
6. Morphological Analysis, N-grams, and N-gram smoothing using NLTK Library
we are given the task
- Write a Python program to
- Perform Morphological Analysis using NLTK library
- Generate n-grams using NLTK N-Grams library
- Implement N-Grams Smoothing.
and the code for that is,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import nltk
from nltk import ngrams, bigrams, pos_tag
from nltk.stem import PorterStemmer, WordNetLemmatizer
from nltk.corpus import wordnet
from nltk.tokenize import word_tokenize
from nltk.probability import ConditionalFreqDist, ConditionalProbDist, LaplaceProbDist
nltk.download('punkt')
nltk.download('punkt_tab')
nltk.download('wordnet')
nltk.download('averaged_perceptron_tagger_eng')
ps = PorterStemmer()
wl = WordNetLemmatizer()
# a) Morphological analysis: stem, lemma, morphy (base form), POS
for w in ['studies', 'honoring', 'better', 'cultural']:
print(w,
"| stem:", ps.stem(w),
"| lemma:", wl.lemmatize(w, 'v'),
"| morphy:", wordnet.morphy(w),
"| POS:", pos_tag([w])[0][1])
# Sentence for n-gram analysis
text = "JKKNIU stands as a dedicated center for higher education, honoring the profound cultural and literary legacy of Bangladesh's national poet."
tokens = word_tokenize(text)
words = [w.lower() for w in tokens if w.isalpha()]
# b) N-grams
for n in (1, 2, 3):
print(f"{n}-grams:", list(ngrams(words, n))[:5])
# c) Bigram smoothing: unsmoothed (MLE) vs Laplace (add-one)
corpus = "the cat sat on the mat the cat ate the fish".split()
cfd = ConditionalFreqDist(bigrams(corpus))
cpd = ConditionalProbDist(cfd, LaplaceProbDist, bins=len(set(corpus)))
print("MLE P(cat|the) =", cfd['the'].freq('cat'))
print("Laplace P(cat|the) =", cpd['the'].prob('cat'))
print("MLE P(dog|the) =", cfd['the'].freq('dog')) # 0 -> zero-probability problem
print("Laplace P(dog|the) =", cpd['the'].prob('dog')) # > 0 after smoothing
7. POS Tag Ambiguity Resolution Using Transition and Emission Probabilities
The same word can carry different POS tags, “can” can be a modal (MD), a noun (NN) or a verb (VB), and “fish” can be a noun or a verb. To resolve this ambiguity we build a small Hidden Markov Model with transition probabilities P(tag_i | tag_i-1) and emission probabilities P(word | tag), then run the Viterbi algorithm over the sentence “I can fish” to find the most probable tag sequence.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import nltk
from nltk.tokenize import word_tokenize
nltk.download('punkt')
nltk.download('punkt_tab')
# Tag ambiguity: "can" -> MD / NN / VB, "fish" -> NN / VB
tags = ['PRP', 'MD', 'VB', 'NN']
# Transition probabilities P(tag_i | tag_i-1); '<s>' = sentence start
trans = {
'<s>': {'PRP': 0.6, 'MD': 0.05, 'VB': 0.05, 'NN': 0.3},
'PRP': {'PRP': 0.01, 'MD': 0.50, 'VB': 0.39, 'NN': 0.10},
'MD': {'PRP': 0.05, 'MD': 0.01, 'VB': 0.84, 'NN': 0.10},
'VB': {'PRP': 0.10, 'MD': 0.01, 'VB': 0.04, 'NN': 0.85},
'NN': {'PRP': 0.05, 'MD': 0.20, 'VB': 0.30, 'NN': 0.45},
}
# Emission probabilities P(word | tag)
emit = {
'PRP': {'i': 0.9},
'MD': {'can': 0.8},
'VB': {'fish': 0.4, 'can': 0.1},
'NN': {'fish': 0.5, 'can': 0.3},
}
sent = [w.lower() for w in word_tokenize("I can fish")]
print("Sentence:", sent)
# Viterbi: best tag sequence = argmax of prod P(tag|prev) * P(word|tag)
V = [{t: trans['<s>'][t] * emit[t].get(sent[0], 0) for t in tags}]
back = [{}]
for i in range(1, len(sent)):
V.append({})
back.append({})
for t in tags:
p, prev = max((V[i-1][pt] * trans[pt][t] * emit[t].get(sent[i], 0), pt) for pt in tags)
V[i][t], back[i][t] = p, prev
# Backtrack
last = max(V[-1], key=V[-1].get)
best = [last]
for i in range(len(sent) - 1, 0, -1):
last = back[i][last]
best.insert(0, last)
for i, w in enumerate(sent):
print(f"{w:6}", {t: round(V[i][t], 5) for t in tags if V[i][t] > 0})
print("Best tag sequence:", list(zip(sent, best)))
print("Probability :", max(V[-1].values()))
the model tags the sentence as [('i', 'PRP'), ('can', 'MD'), ('fish', 'VB')], the modal-verb reading wins because P(MD | PRP) * P(can | MD) is the strongest path through the sentence.
8. Grapheme-to-Phoneme (G2P) Conversion
G2P conversion turns the spelling of a word (graphemes) into its pronunciation (phonemes). the code first looks the word up in the CMU Pronouncing Dictionary, and for words that are not in the dictionary, like proper nouns, it falls back to rule-based letter-to-sound rules, longest match first.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import nltk
from nltk.corpus import cmudict
nltk.download('cmudict')
cmu = cmudict.dict()
# Rule-based fallback for words not in the dictionary (longest match first)
rules = [('tch', 'CH'), ('igh', 'AY'), ('sh', 'SH'), ('ch', 'CH'), ('th', 'TH'),
('ph', 'F'), ('ck', 'K'), ('ng', 'NG'), ('ee', 'IY'), ('oo', 'UW'),
('ai', 'EY'), ('oa', 'OW'), ('a', 'AE'), ('e', 'EH'), ('i', 'IH'),
('o', 'AA'), ('u', 'AH'), ('b', 'B'), ('c', 'K'), ('d', 'D'),
('f', 'F'), ('g', 'G'), ('h', 'HH'), ('j', 'JH'), ('k', 'K'),
('l', 'L'), ('m', 'M'), ('n', 'N'), ('p', 'P'), ('q', 'K'),
('r', 'R'), ('s', 'S'), ('t', 'T'), ('v', 'V'), ('w', 'W'),
('x', 'K S'), ('y', 'Y'), ('z', 'Z')]
def g2p(word):
word = word.lower()
if word in cmu: # a) dictionary lookup
return cmu[word][0], 'cmudict'
out, i = [], 0 # b) rule-based fallback
while i < len(word):
for g, p in rules:
if word.startswith(g, i):
out += p.split()
i += len(g)
break
else:
i += 1
return out, 'rules'
for w in ['university', 'night', 'phone', 'school', 'nazrul', 'jkkniu']:
ph, src = g2p(w)
print(f"{w:12}{' '.join(ph):30}({src})")
w = input("Enter a word: ")
print(w, "->", ' '.join(g2p(w)[0]))
university, night, phone and school come straight from the dictionary, while nazrul and jkkniu are built by the fallback rules, for example nazrul -> N AE Z R AH L.
9. Text-to-Speech (TTS) for Converting Text into Audio
NLTK itself has no audio support, so gTTS fills the text-to-speech part. converting the given text into an audio file,
1
2
3
4
5
6
7
8
9
from gtts import gTTS
msg = ("Jatiya Kabi Kazi Nazrul Islam University (JKKNIU) is a premier public university "
"in Trishal, Mymensingh, established in 2006.")
# Text-to-Speech
tts = gTTS(msg, lang='en')
tts.save('jkkniu.mp3')
print("Text converted to speech: jkkniu.mp3")
10. Automatic Speech Recognition (ASR) for Converting Audio into Text
converting the audio file from task 9 back into text. the recognizer reads WAV files, so the MP3 is converted first with pydub, which needs ffmpeg installed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from pydub import AudioSegment
import speech_recognition as sr
# Convert MP3 to WAV (recognizer needs WAV)
audio = AudioSegment.from_mp3('jkkniu.mp3')
audio.export('jkkniu.wav', format='wav')
print("MP3 converted to WAV: jkkniu.wav")
# Speech-to-Text
r = sr.Recognizer()
with sr.AudioFile('jkkniu.wav') as source:
audio_data = r.record(source)
text = r.recognize_google(audio_data)
print("Recognized:", text)
Complete Code for memorization is,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# pip install nltk gTTS SpeechRecognition pydub (pydub needs ffmpeg)
import nltk
for p in ['punkt', 'punkt_tab', 'stopwords', 'wordnet', 'omw-1.4',
'averaged_perceptron_tagger', 'averaged_perceptron_tagger_eng', 'cmudict']:
nltk.download(p, quiet=True)
text = ("JKKNIU stands as a dedicated center for higher education, honoring "
"the profound cultural and literary legacy of Bangladesh's national poet.")
# ---------- 1. Tokenization + Stop word removal ----------
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.corpus import stopwords
tokens = word_tokenize(text)
print("Tokens:", tokens)
print("Sentences:", sent_tokenize(text))
stop = set(stopwords.words('english'))
filtered = [w for w in tokens if w.lower() not in stop and w.isalnum()]
print("After stop word removal:", filtered)
# ---------- 2. Word analysis + Word generation ----------
from nltk import FreqDist
from nltk.stem import PorterStemmer, WordNetLemmatizer
from nltk.corpus import wordnet
# a) Word analysis: frequency, length, root and affix
words = [w.lower() for w in tokens if w.isalpha()]
print("Total:", len(words), "| Unique:", len(set(words)))
print("Most common:", FreqDist(words).most_common(3))
ps, wl = PorterStemmer(), WordNetLemmatizer()
for w in ['honoring', 'dedicated', 'stands']:
stem = ps.stem(w)
print(w, "| length:", len(w), "| stem:", stem,
"| lemma:", wl.lemmatize(w, 'v'), "| suffix:", w[len(stem):])
# b) Word generation: root + suffixes, keep only real words
root = 'play'
suffixes = ['', 's', 'ed', 'ing', 'er', 'ers', 'ful', 'ly', 'able']
generated = [root + s for s in suffixes if wordnet.synsets(root + s)]
print("Generated words:", generated)
# ---------- 3. Word Sense Disambiguation (Lesk) ----------
from nltk.wsd import lesk
samples = [('bank', "I deposited money in the bank"),
('bank', "We sat on the bank of the river"),
('bat', "He hit the ball with a bat"),
('bass', "He plays the bass guitar in a band"),
('plant', "The plant produces electricity for the city"),
('spring', "Water flows from the spring in the hill")]
for word, sent in samples:
sense = lesk(word_tokenize(sent), word)
print(word, "->", sense, ":", sense.definition() if sense else "no sense found")
# ---------- 4. Stemming ----------
from nltk.stem import LancasterStemmer, SnowballStemmer
ws = ['running', 'flies', 'happily', 'studies', 'generously', 'connected']
porter, lancaster, snowball = PorterStemmer(), LancasterStemmer(), SnowballStemmer('english')
print(f"{'word':12}{'porter':10}{'lancaster':12}{'snowball'}")
for w in ws:
print(f"{w:12}{porter.stem(w):10}{lancaster.stem(w):12}{snowball.stem(w)}")
# ---------- 5. POS tagging of a word list + lookup ----------
from nltk import pos_tag
wlist = ['run', 'beautiful', 'quickly', 'university', 'she',
'and', 'under', 'eat', 'happy', 'book', 'the', 'they']
tags = dict(pos_tag(wlist))
print(tags)
w = input("Enter a word: ").lower()
print(w, "->", tags.get(w) or pos_tag([w])[0][1])
# ---------- 6. Morphology, N-grams, Smoothing ----------
from nltk import ngrams, bigrams
from nltk.probability import ConditionalFreqDist, ConditionalProbDist, LaplaceProbDist
# a) Morphological analysis: stem, lemma, morphy (base form), POS
for w in ['studies', 'honoring', 'better', 'cultural']:
print(w, "| stem:", ps.stem(w), "| lemma:", wl.lemmatize(w, 'v'),
"| morphy:", wordnet.morphy(w), "| POS:", pos_tag([w])[0][1])
# b) N-grams
for n in (1, 2, 3):
print(f"{n}-grams:", list(ngrams(words, n))[:5])
# c) Bigram smoothing: unsmoothed (MLE) vs Laplace (add-one)
corpus = "the cat sat on the mat the cat ate the fish".split()
cfd = ConditionalFreqDist(bigrams(corpus))
cpd = ConditionalProbDist(cfd, LaplaceProbDist, bins=len(set(corpus)))
print("MLE P(cat|the) =", cfd['the'].freq('cat'))
print("Laplace P(cat|the) =", cpd['the'].prob('cat'))
print("MLE P(dog|the) =", cfd['the'].freq('dog')) # 0 -> zero-probability problem
print("Laplace P(dog|the) =", cpd['the'].prob('dog')) # > 0 after smoothing
# ---------- 7. POS tag ambiguity: HMM + Viterbi ----------
# Tag ambiguity: "can" -> MD / NN / VB, "fish" -> NN / VB
tags = ['PRP', 'MD', 'VB', 'NN']
# Transition probabilities P(tag_i | tag_i-1); '<s>' = sentence start
trans = {
'<s>': {'PRP': 0.6, 'MD': 0.05, 'VB': 0.05, 'NN': 0.3},
'PRP': {'PRP': 0.01, 'MD': 0.50, 'VB': 0.39, 'NN': 0.10},
'MD': {'PRP': 0.05, 'MD': 0.01, 'VB': 0.84, 'NN': 0.10},
'VB': {'PRP': 0.10, 'MD': 0.01, 'VB': 0.04, 'NN': 0.85},
'NN': {'PRP': 0.05, 'MD': 0.20, 'VB': 0.30, 'NN': 0.45},
}
# Emission probabilities P(word | tag)
emit = {
'PRP': {'i': 0.9},
'MD': {'can': 0.8},
'VB': {'fish': 0.4, 'can': 0.1},
'NN': {'fish': 0.5, 'can': 0.3},
}
sent = [w.lower() for w in word_tokenize("I can fish")]
V = [{t: trans['<s>'][t] * emit[t].get(sent[0], 0) for t in tags}]
back = [{}]
for i in range(1, len(sent)):
V.append({})
back.append({})
for t in tags:
p, prev = max((V[i-1][pt] * trans[pt][t] * emit[t].get(sent[i], 0), pt) for pt in tags)
V[i][t], back[i][t] = p, prev
last = max(V[-1], key=V[-1].get)
best = [last]
for i in range(len(sent) - 1, 0, -1):
last = back[i][last]
best.insert(0, last)
print("Best tag sequence:", list(zip(sent, best)))
# ---------- 8. Grapheme-to-Phoneme ----------
from nltk.corpus import cmudict
cmu = cmudict.dict()
# Rule-based fallback for words not in the dictionary (longest match first)
rules = [('tch', 'CH'), ('igh', 'AY'), ('sh', 'SH'), ('ch', 'CH'), ('th', 'TH'),
('ph', 'F'), ('ck', 'K'), ('ng', 'NG'), ('ee', 'IY'), ('oo', 'UW'),
('ai', 'EY'), ('oa', 'OW'), ('a', 'AE'), ('e', 'EH'), ('i', 'IH'),
('o', 'AA'), ('u', 'AH'), ('b', 'B'), ('c', 'K'), ('d', 'D'),
('f', 'F'), ('g', 'G'), ('h', 'HH'), ('j', 'JH'), ('k', 'K'),
('l', 'L'), ('m', 'M'), ('n', 'N'), ('p', 'P'), ('q', 'K'),
('r', 'R'), ('s', 'S'), ('t', 'T'), ('v', 'V'), ('w', 'W'),
('x', 'K S'), ('y', 'Y'), ('z', 'Z')]
def g2p(word):
word = word.lower()
if word in cmu: # a) dictionary lookup
return cmu[word][0], 'cmudict'
out, i = [], 0 # b) rule-based fallback
while i < len(word):
for g, p in rules:
if word.startswith(g, i):
out += p.split()
i += len(g)
break
else:
i += 1
return out, 'rules'
for w in ['university', 'night', 'phone', 'school', 'nazrul', 'jkkniu']:
ph, src = g2p(w)
print(f"{w:12}{' '.join(ph):30}({src})")
# ---------- 9. Text-to-Speech ----------
# NLTK has no audio support, so use gTTS (text->speech) and SpeechRecognition (speech->text). Needs internet.
from gtts import gTTS
from pydub import AudioSegment
import speech_recognition as sr
msg = ("Jatiya Kabi Kazi Nazrul Islam University (JKKNIU) is a premier "
"public university in Trishal, Mymensingh, established in 2006.")
gTTS(msg, lang='en').save('jkkniu.mp3')
# ---------- 10. Speech-to-Text ----------
# Recognizer reads WAV, so convert the mp3 first
AudioSegment.from_mp3('jkkniu.mp3').export('jkkniu.wav', format='wav')
r = sr.Recognizer()
with sr.AudioFile('jkkniu.wav') as source:
print("Recognized:", r.recognize_google(r.record(source)))