Biognorics
Autognorics introduces new concepts like embedded inscriptions, intuitive objects, and generated emergence. These are the essential ingredients in creating synthetic living objects, machines, or systems.
How to install Python.
1. Download Python.
2. Download Pycharm. (your text editor).
3. Install pyttsx3 (text to voice).
C:\Users\username\PycharmProjects\pythonProject\venv\Scripts
4. Enter script below on pycharm.
import pyttsx3
spk = pyttsx3.init()
spk.say("Hi there ... I am a Gnorics")
spk.say("I can react to you like a human being.")
spk.runAndWait()
5. Run
To test arduino/python interface:
- - - - - - - - - - - - - - - Arduino - - - - - - - - - - - - - - - - - - - - - -
int x=0;
void setup() {
pinMode( 13 , OUTPUT );
Serial.begin(9600);
}
void loop() {
if(Serial.available() > 0)
{
x=Serial.read();
}
if(x == '1')
{
digitalWrite( 13 , HIGH );
}
else if(x == '2')
{
digitalWrite( 13, LOW);
}
}
- - - - - - - - - - - - - - - - - - - -Python - - - - - - - - - - - - - - - - -
For PyCharm:
import serial
import time
arduino=serial.Serial('COM#', 9600)
time.sleep(2)
print("Type 1 to turn ON LED and 2 to turn OFF LED")
while 1: #loop
x=input()
if x == '1':
arduino.write(b'1')
print("LED turned ON")
elif x == '2':
arduino.write(b'2')
print("LED turned OFF")
- - - - - - - - - - - - - - - - - loop - - - - - - - - - - - - - - - - - - - -
import serial
import time
# arduino = serial.Serial('COM5', 9600)
for i in range(20):
with serial.Serial('COM5', 9600, timeout=1) as arduino:
time.sleep(0.5)
arduino.write(b'1')
time.sleep(0.5)
arduino.write(b'0')
print(i)
arduino.close()
exit()
- - - - - - - - - - - - - - - - - - - option 1 - - - - - - - - - - - - - - - - - -
import serial #pyserial
import time
ser = serial.Serial('COM#', 9600, timeout=1)
def led_on_off():
vinput = input("\n Type on / off / quit : ")
if vinput == "on":
print("LED is on...")
time.sleep(0.1)
ser.write(b'1')
led_on_off()
elif vinput == "off":
print("LED is off...")
time.sleep(0.1)
ser.write(b'2')
led_on_off()
elif vinput == "quit" or vinput == "q":
print("Program terminated")
time.sleep(0.1)
ser.write(b'L')
ser.close()
else:
print("Invalid input.")
led_on_off()
time.sleep(2)
led_on_off()
- - - - - - - - - - - - - - - - - - - - - - - loop - - - - - - - -- - - - -
import serial
import time
# arduino = serial.Serial('COM#', 9600)
while 1:
# for i in range(20):
with serial.Serial('COM#', 9600, timeout=1) as arduino:
time.sleep(0.5)
arduino.write(b'1')
time.sleep(0.5)
arduino.write(b'0')
# print(i)
arduino.close()
exit()
- - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - -- -- -- --
import pyttsx3
engine = pyttsx3.init() # object creation
""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print (rate) #printing current voice rate
engine.setProperty('rate', 125) # setting up new voice rate
"""VOLUME"""
volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1)
print (volume) #printing current volume level
engine.setProperty('volume',1.0) # setting up volume level between 0 and 1
"""VOICE"""
voices = engine.getProperty('voices') #getting details of current voice
#engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female
engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()
"""Saving Voice to a file"""
# On linux make sure that 'espeak' and 'ffmpeg' are installed
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Needs: Command prompt for PIP, Pycharm for python editor, Arduino IDE, Python
A good source for python programming: https://datatofish.com/python-tutorials/
print ("Hey! My name is JC.")
print ("I'm a coding enthusiast and freelance web/graphic designer.")
print ("Currently working on Python, JAVA and C++")
print ("and interested in network installations and troubleshooting.")
Disclaimer: We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email for guidance and technical support.
Public Domain Notice: Copyright (c) 1988. All rights reserved. This article is part of a book entitled Autognorics. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: Inscription by Design, Joey Lawsin, 1988, USA.
Patent Pending. 2000 © ®
Comments
Post a Comment