Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--- #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Dictowriter_kbdinput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os
import time
import threading

buffer = "welcome to project dicto-writer 1.0"
oneline = 30
scale = 0.3 # goes well with line yoffset drop of 10
cmd = "./h2g/src/hf2gcode" # ./prog -params "text"
gcd_file = "write.txt"
current_line = 40

def speech_recog():
while(len(buffer) <= 30):
new_msg = input("write something:")
buffer + new_msg

def gen_gcode(mesg,x,y):
# print(scale)
print("generating GCODE")
x,y = str(x),str(y)
sca = str(scale)
bashout = cmd +" -o " +gcd_file+" --scale "+sca+" -x "+ x +" -y "+ y + " " + "\"" +mesg +"\""
# bashout = cmd +" --scale "+sca+" -x "+ x +" -y "+ y + " " + "\"" +mesg +"\""
# print(bashout)
return os.system(bashout)


def run_plotter(filename):
print("plotter is writing "+buffer)
# cmd2 = "gcd -c v3.json -f write.txt"
cmd2 = "gcd -c v3.json -f "+filename
os.system(cmd2)

## need to use one thread to fill the buffer by speech recognition
# speech_t = threading.Thread(target = speech_recog)
# speech_t.start()

while(True):
if(len(buffer) >= oneline):
gen_gcode(buffer,0,current_line) #text , xoffset , yoffset
current_line -= 10 #step down a line
run_plotter("write.txt") # pass the gcode
buffer="" #clear buffer
# speech_recog()
time.sleep(0.5) # simply
buffer += input("fill buffer :")

160 changes: 160 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,162 @@
![/github/commits/hackerminds/DICTO-WRITTER/](https://badgen.net/github/commits/hackerminds/DICTO-WRITTER/)
![https://badgen.net/github/last-commit/hackerminds/DICTO-WRITTER/](https://badgen.net/github/last-commit/hackerminds/DICTO-WRITTER/)


# DICTO-WRITTER
This project is about building a mechanical prototype of a Speech to Text Plotter able to write on the given solid surface. Also trying to build a speech synthesizer as the feed back system.

### This is a final-year engineering project undertaken by me and my friends.

## STEP 1: Setting up Google Speech recognition

### To build a speech to text converter using the raspberry pi


### Use a usb microphone
## or ..
#### Checking Sound card modules:
```sh
pi@raspberrypi:~ $ cat /proc/asound/modules
1 snd_usb_audio
pi@raspberrypi:~ $ cat /proc/asound/cards
1 [Device ]: USB-Audio - USB PnP Sound Device
C-Media Electronics Inc. USB PnP Sound Device at usb-3f980000.usb-1.5, full spe
```
#### Configuring ALSA:
We simply need to tell ALSA what our default PCM card index should be and in what order they should be prioritized in the kernel.
```sh
#cat ~/.asoundrc
cat << EOF | tee ~/.asoundrc

pcm.!default {
type hw
card 1
}

ctl.!default {
type hw
card 1
}
EOF

sudo nano /usr/share/alsa/alsa.conf
```
### then replace:
```sh
#defaults.ctl.card 0
#defaults.pcm.card 0
```
### with:
```sh
defaults.ctl.card 1
defaults.pcm.card 1
```
## STEP 2: TEXT TO CNC CODE(GCODE)

### SOLID WAY:
To use a library that converts text to gcode
FIXED : HF2GCODE IS BEST SOLUTION (CONFIRMED )

## Colab notebook to generate gcode
https://colab.research.google.com/drive/1zbTVsNTEt2G8f_w0fMJnD0CR2OUvcBxd

### Installation
```sh
wget https://github.com/hackerminds/Dicto_Writer/raw/master/hf.zip
unzip hf.zip
cd hf2gcode-master/src
make # COMPILE THE C SOURCE CODE
mv hf2gcode-master h2g # RENAME FOLDER
```
```sh
cd h2g/src
./hf2gcode -font "rowmans" -y 0 -x 0 -o text_to_write.gcd --min-gcode "Welcome to DictoWriter!"
```
#### SOURCE CODE : https://github.com/Andy1978/hf2gcode

### DOESNT WORK ON Pi 3B+
The G-CODE interpreter for Raspberry Pi 3 (it works on older versions, but untested)
Sending the gcode (direct on raspi):

```sh
gcd -c settings.json -f text_to_write.gcd
```
#### SOURCE CODE: https://github.com/pantadeusz/raspigcd

(EXAMPLE:)https://www.hackster.io/news/skip-the-control-board-and-run-your-cnc-stepper-drivers-directly-from-a-raspberry-pi-b5666f403f71

### Gcode Notes
----------------
> **remember** concept of Gcode is moving the pen/tool from one vertice to another.

> Gcode is always read from top to bottom , this process will connect the vertices sequentially (by action of pen)

> For better understanding think of Gcode as concept of relative positioning to origin (0,0)

|code|desc|
|---|---|
|G0 | pen action off or pen writing off
|G1 | pen action on

> **(in case of pen , instead of G , the Z value matters because pen can write as soon as it touches the paper! ,where as, the tool needs to be rotating fast enough to cut through the subject.)**

|code|desc|
|---|---|
|Z0 | pen down or touching paper
|Z1 | pen up

|code|desc|
|---|---|
|X0 Y1| moves pen to vertice (0,1)
|X0.5 Y4 | moves pen to vertice (0.5,4)

> try this online simulator ( you can copy paste the code below)
> https://ncviewer.com/
> FOR BETTER UNDERSTANDING ( USE HIDE TOOLPATH AFTER POSITION )

|code|desc|
|---|---|
|N |this is just the sequence number or SI. no of instruction
|( )| parenthesis are treated as comments
|I2.0 J3.5| arc from the x and y position


### gcode meaning:
http://www.linuxcnc.org/docs/html/gcode/g-code.html#gcode:g7


# ADDITIONAL CONTENTS (OPT):

#### TYPES OF GCODE:
Linux cnc gcode is different https://www.youtube.com/watch?v=171SuRjzNcQ

#### Linux cnc on raspi
https://www.youtube.com/results?search_query=linuxcnc+on+raspberry+pi+3+

#### Linux cnc docs
http://linuxcnc.org/docs/

#### (topic of dicsussion on types of gcode)
https://forum.linuxcnc.org/20-g-code/26733-translating-other-g-code-formats-to-ngc

#### info:
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_LinuxCNC_G-Code_Generators#Multi_line_Text_Engraving_Software

#### (PYTHON CODE but its linux cnc gcode (dont know how to use) :
https://github.com/LinuxCNC/simple-gcode-generators/tree/master/engrave-lines

#### (JAVA CODE(just a lil hesitation to use)): https://github.com/misan/gcodeFont

#### ALTERNATIVE WAY ( No more needed ):
Make a python script to scrap web by using python auto web form filling on this site
Service page : https://www.microtechstelladata.com/TextToNCcode.aspx
Trick : https://learn.onemonth.com/automate-web-forms-with-python/

#### UNIVERSAL GCODE SENDER
https://youtu.be/u35L0jGCqFc


#### SETUP FOR MECHANICAL BODY

https://arnabkumardas.com/cnc.html

Loading