Skip to content

Instantly share code, notes, and snippets.

@AkBKukU
Created September 10, 2022 18:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AkBKukU/922343e0d638da678ea8af67cefe96fc to your computer and use it in GitHub Desktop.
Save AkBKukU/922343e0d638da678ea8af67cefe96fc to your computer and use it in GitHub Desktop.
Python script for writing to DECtalk devices with resets for commands
#!/usr/bin/python3
import serial
import sys
# DECtalk output over serial with command resetting
ser = serial.Serial('/dev/ttyUSB0',9600,timeout=1) # open serial port with 9600 8N1 defaults
print(ser.name) # check which port was really used
for line in sys.stdin:
# ser.write( bytes(str(line),'ascii') ) # No command resetting
ser.write( bytes(str(line)+str('^K\r [:nh][:dv ap 90 pr 0].END OF LINE[:np][:pp 0][:cp 0][:rate 200][:say line][:punct none][:pitch 35].\r'),'ascii') ) # DTC01 Reset with CTRL+K escape sequence
# ser.write( bytes(str(line)+str('[:phonem off][:nh][:dv ap 90 pr 0].END OF LINE[:np][:pp 0][:cp 0][:rate 200][:say line][:punct none][:pitch 35].\r'),'ascii') ) # Newer DECtalk versions reset
ser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment