It's been a long way so far, and I don't know what it is anymore, but I would like to leave it as a reference site for myself. Use raspberryPi and julus (speech recognition). ① Microphone Use julius (speech recognition) on raspberry Pi. ② Installation Use raspberry Pi and Julius (speech recognition). ③ Dictionary creation Use raspberry Pi and Julius (speech recognition). ④ L Chika Use raspberry Pi and Julius (speech recognition). ⑤ i2c character display
AQM0802 (using the completed version of the i2c connection small display) Jumper wire (male-female) 4-5 raspberryPi 3B+ USB microphone
Set the i2c usage of Raspberry Pi. The pin layout is UDD, RESET, SCL, SDA, GND from the top, so wire with reference to the image below. Quoted from Using LCD Module with Raspberry Pi
Check the connection.
$ sudo i2cdetect -y 1
I was able to confirm that it was connected with 3e.
I2C_LCD_TEST.sh
#!/bin/sh
# AQM0802A Raspberry Pi I2C control
# http://www.neko.ne.jp/~freewing/
# http://akizukidenshi.com/catalog/g/gP-06669/
# sudo nano I2C_LCD_TEST.sh
# sudo chmod 755 I2C_LCD_TEST.sh
# ./I2C_LCD_TEST.sh
#AQM0802A LCD initialization
# 0x38 0x39 Function Set
i2cset -y 1 0x3e 0x00 0x38 0x39 i
# 0x10 Bias selection/Internal OSC frequency adjust
# 0x70 Contrast set(low byte)
# 0x56 Power/ICON control/Contrast set(high byte)
# 0x6C Follower control
i2cset -y 1 0x3e 0x00 0x10 0x70 0x56 0x6C i
sleep 0.3
# 0x38 Function Set
i2cset -y 1 0x3e 0x00 0x38 i
# 0x02 Return Home
i2cset -y 1 0x3e 0x00 0x02 i
# 0x0C Display ON/OFF control
# i2cset -y 1 0x3e 0x00 0x0C i
# 0x0F Display ON/OFF control
i2cset -y 1 0x3e 0x00 0x0F i
# 0x01 Clear Display
i2cset -y 1 0x3e 0x00 0x01 i
sleep 0.5
# 0x40 CGRAM addres = 0x00 CHARACTER CODE = 0x00
i2cset -y 1 0x3e 0x00 0x40 b
i2cset -y 1 0x3e 0x40 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 i
# 0x40 CGRAM addres = 0x08 CHARACTER CODE = 0x01
i2cset -y 1 0x3e 0x00 0x48 b
i2cset -y 1 0x3e 0x40 0x1F 0x1E 0x1D 0x1C 0x1B 0x1A 0x19 0x18 i
#1st line DDRAM address= 0x00
i2cset -y 1 0x3e 0x00 0x80 b
# "=FREE =="
i2cset -y 1 0x3e 0x40 0x3D 0x46 0x52 0x45 0x45 0x20 0x3D 0x3D i
sleep 0.5
#2nd line DDRAM address= 0x40
i2cset -y 1 0x3e 0x00 0xc0 b
# "== WING="
i2cset -y 1 0x3e 0x40 0x3D 0x3D 0x20 0x57 0x49 0x4E 0x47 0x3D i
$ chmod 755 I2C_LCD_TEST.sh
$ sudo ./I2C_LCD_TEST.sh
How to connect the I2C communication type LCD module AQM0802A to GPIO of Raspberry Pi 3 is being tried as it is. You can see that the display works.
# Screen initialization
$ i2cset -y 1 0x3e 0x00 0x38 0x39 0x14 0x70 0x56 0x6c i
$ i2cset -y 1 0x3e 0x00 0x38 0x0c 0x01 i
$ i2cset -y 1 0x3e 0x00 0x80
#Erase everything and move the cursor to the beginning of the first line
sudo i2cset -y 1 0x3e 0 0x38 0x0d 0x01 i
#Display specified data continuously
sudo i2cset -y 1 0x3e 0x40 [data1] [data2] [data3] i
#Start a new line and move the cursor to the beginning
sudo i2cset -y 1 0x3e 0x00 0xc0 i
0x3e is the write target (I2CBUS). i is "block data", a specification to write data continuously. b is a normal write in bytes. Character display of AQM0802 Quote Display characters on LCD display with Raspberry Pi zero Detailed explanation of I2C command of Rasberry PI
The word display is created by referring to the character patterns of AQM0802.
#Thank You
sudo i2cset -y 1 0x3e 0x40 0xb1 0xd8 0xb6 0xde 0xc4 0xb3 i
Ari Kato U
#Hello
sudo i2cset -y 1 0x3e 0x40 0xba 0xdd 0xc6 0xc1 0xca i
Hello
test_i2c001.py
#!usr/bin/env python
# -*- coding: utf-8 -*-
import smbus
import time
import subprocess
import socket
import string
i2c = smbus.SMBus(1) # 1 is bus number
addr02=0x3e #lcd
_command=0x00
_data=0x40
_clear=0x01
_home=0x02
display_On=0x0f
LCD_2ndline=0x40+0x80
#LCD AQM0802/1602
def command( code ):
i2c.write_byte_data(addr02, _command, code)
time.sleep(0.1)
def writeLCD( message ):
mojilist=[]
for moji in message:
mojilist.append(ord(moji))
i2c.write_i2c_block_data(addr02, _data, mojilist)
time.sleep(0.1)
def init ():
command(0x38)
command(0x39)
command(0x14)
command(0x73)
command(0x56)
command(0x6c)
command(0x38)
command(_clear)
command(display_On)
def ari ():
arigatoulist=[0xb1, 0xd8, 0xb6, 0xde, 0xc4, 0xb3]
i2c.write_i2c_block_data(addr02, _data, arigatoulist)
time.sleep(0.1)
print(arigatoulist)
def konnichiha():
konnichihalist=[0xba, 0xdd, 0xc6, 0xc1, 0xca]
i2c.write_i2c_block_data(addr02, _data, konnichihalist)
time.sleep(0.1)
HOST = '127.0.0.1' #IP address of julius server
PORT = 10500 #julius server listening port
DATESIZE = 1024 #Number of received data bytes
class Julius:
def __init__(self):
self.sock = None
def run(self):
#Connect to julius server with socket communication
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as self.sock:
self.sock.connect((HOST, PORT))
strTemp = "" #Variable to store spoken words
fin_flag = False #End of story flag
while True:
#Receive data from julius server
data = self.sock.recv(DATESIZE).decode('utf-8')
for line in data.split('\n'):
#From the received data<WORD>Extract the words written after and store them in a variable.
# <WORD>After, the spoken words are listed.
index = line.find('WORD="')
if index != -1:
#Store the words spoken in strTemp
strTemp = strTemp + line[index+6:line.find('"',index+6)]
#For received data</RECOGOUT>'If there is, the story ends ⇒ Set the flag to True
if '</RECOGOUT>' in line:
fin_flag = True
#Execute a print statement for each word spoken
if fin_flag == True:
if 'Thank you' in strTemp:
print("You are welcome")
init ()
command(_clear)
ari()
elif 'Hello' in strTemp:
print("Good evening")
init ()
command(_clear)
konichiwa()
else:
print("Spoken words:" + strTemp)
fin_flag = False
strTemp = ""
if __name__ == "__main__":
julius = Julius()
julius.run()
Create a Japanese dictionary file according to the character patterns of AQM0802.
nihongo.py
nihongo = {"Ah":0xb1,
"I":0xb2,
"U":0xb3,
"e":0xb4,
"O":0xb5,
"Or":0xb6,
"Ki":0xb7,
"Ku":0xb8,
"Ke":0xb9,
"This":0xba,
"Sa":0xbb,
"Shi":0xbc,
"Su":0xbd,
"Se":0xbe,
"So":0xbf,
"Ta":0xc0,
"Chi":0xc1,
"Tsu":0xc2,
"hand":0xc3,
"When":0xc4,
"Nana":0xc5,
"To":0xc6,
"Nu":0xc7,
"Ne":0xc8,
"of":0xc9,
"Is":0xca,
"Hi":0xcb,
"Fu":0xcc,
"What":0xcd,
"Ho":0xce,
"Ma":0xcf,
"Mi":0xd0,
"Mu":0xd1,
"Me":0xd2,
"Also":0xd3,
"Or":0xd4,
"Yu":0xd5,
"Yo":0xd6,
"Et al.":0xd7,
"Ri":0xd8,
"Ru":0xd9,
"Re":0xda,
"Ro":0xdb,
"Wow":0xdc,
"Hmm":0xdd,
"To":0xa6,
"Ah":0xa7,
"I":0xa8,
"U":0xa9,
"Eh":0xaa,
"Mm":0xab,
"Ya":0xac,
"Shu":0xad,
"Yo":0xad,
"Tsu":0xaf,
"But":"182 222",
"Gi":"183 222",
"Gu":"184 222",
"Ge":"185 222",
"Go":"186 222",
"Za":"187 222",
"Ji":"188 222",
"Zu":"189 222",
"Ze":"190 222",
"I'm sorry":"191 222",
"Is":"192 222",
"Ji":"193 222",
"Zu":"194 222",
"so":"195 222",
"Do":"196 222",
"If":"202 222",
"And":"203 222",
"Bu":"204 222",
"Be":"205 222",
"Bo":"206 222",
"Pa":"202 223",
"Pi":"203 223",
"Pu":"204 223",
"Pe":"205 223",
"Po":"206 223"
}
test_i2c003.py
#!usr/bin/env python
# -*- coding: utf-8 -*-
import smbus
import time
import subprocess
import socket
import string
from nihongo import nihongo
i2c = smbus.SMBus(1) # 1 is bus number
addr02=0x3e #lcd
_command=0x00
_data=0x40
_clear=0x01
_home=0x02
display_On=0x0f
LCD_2ndline=0x40+0x80
#LCD AQM0802/1602
def command( code ):
i2c.write_byte_data(addr02, _command, code)
time.sleep(0.1)
def word( message ):
kotoba = []
for moji in message:
kotoba.append(moji)
wordlist = []
for idx in range(0, len(kotoba)):
a = kotoba[idx]
val = nihongo[a]
if type(val) is int:
wordlist.append(val)
else:
nums = val.split()
for i in range(2):
wordlist.append(int(nums[i]))
print(wordlist)
i2c.write_i2c_block_data(addr02, _data, wordlist)
time.sleep(0.1)
def init ():
command(0x38)
command(0x39)
command(0x14)
command(0x73)
command(0x56)
command(0x6c)
command(0x38)
command(_clear)
command(display_On)
HOST = '127.0.0.1' #IP address of julius server
PORT = 10500 #julius server listening port
DATESIZE = 1024 #Number of received data bytes
class Julius:
def __init__(self):
self.sock = None
def run(self):
#Connect to julius server with socket communication
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as self.sock:
self.sock.connect((HOST, PORT))
strTemp = "" #Variable to store spoken words
fin_flag = False #End of story flag
while True:
#Receive data from julius server
data = self.sock.recv(DATESIZE).decode('utf-8')
for line in data.split('\n'):
#From the received data<WORD>Extract the words written after and store them in a variable.
# <WORD>After, the spoken words are listed.
index = line.find('WORD="')
if index != -1:
#Store the words spoken in strTemp
strTemp = strTemp + line[index+6:line.find('"',index+6)]
#For received data</RECOGOUT>'If there is, the story ends ⇒ Set the flag to True
if '</RECOGOUT>' in line:
fin_flag = True
#Execute a print statement for each word spoken
if fin_flag == True:
print(strTemp[4:-3])
init ()
command(_clear)
word(strTemp[4:-3])
fin_flag = False
strTemp = ""
if __name__ == "__main__":
julius = Julius()
julius.run()
Recommended Posts