Commit a23f3ee9 authored by Gareth Smith's avatar Gareth Smith

Merge branch 'patch-1' into 'master'

Added method to read out wire numbers using speakers. Changed output format.

See merge request gsmith/caen-sy-502-tensiometer!1
parents ace7a762 921524cb
......@@ -3,6 +3,9 @@ from time import sleep
import sys
import argparse
import numpy as np
from gtts import gTTS
from playsound import playsound
import os
def initialize():
try:
......@@ -90,6 +93,12 @@ def average(data):
if ok:
return np.average(x)
return -1.0
def vocalize(string):
tts = gTTS(string)
tts.save('vocal_string.mp3')
playsound('vocal_string.mp3')
os.remove('vocal_string.mp3')
if __name__=='__main__':
......@@ -120,10 +129,12 @@ if __name__=='__main__':
try:
current_wire = start_wire
print('wire #\t avg [us]')
while True:
vocalize(f'Next wire {current_wire}')
data = run(serial_port,current_wire,interval,current_wire==start_wire)
avg = average(data)
print('wire #',current_wire,':', avg, 'us')
print(current_wire, avg)
current_wire += 1
except KeyboardInterrupt:
serial_port.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment