Spaces:
Restarting
Restarting
File size: 1,258 Bytes
7bc29af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import numpy as np
# import praatio
# import praatio.praat_scripts
import os
import sys
import random
import csv
# praatEXE = join('.',os.path.abspath(os.getcwd()) + r"\Praat.exe")
def CSVutil(file, rw, type, *args):
if type == "formanting":
if rw == "r":
with open(file) as fileCSVread:
csv_reader = list(csv.reader(fileCSVread))
return (
(csv_reader[0][0], csv_reader[0][1], csv_reader[0][2])
if csv_reader is not None
else (lambda: exec('raise ValueError("No data")'))()
)
else:
if args:
doformnt = args[0]
else:
doformnt = False
qfr = args[1] if len(args) > 1 else 1.0
tmb = args[2] if len(args) > 2 else 1.0
with open(file, rw, newline="") as fileCSVwrite:
csv_writer = csv.writer(fileCSVwrite, delimiter=",")
csv_writer.writerow([doformnt, qfr, tmb])
elif type == "stop":
stop = args[0] if args else False
with open(file, rw, newline="") as fileCSVwrite:
csv_writer = csv.writer(fileCSVwrite, delimiter=",")
csv_writer.writerow([stop])
|