Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

csv2grid.py 958 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import pandas as pd
  2. import pympi.Praat as pr
  3. #open csv as pandas dataframe
  4. df = pd.read_csv(r"C:\Users\Martin\Desktop\LAAC\alignment-project\inputs\testCHA.csv")
  5. #create textgrid
  6. grid = pr.TextGrid(xmax = 300)
  7. #specify number of rows
  8. rows = 9000
  9. #iterate through each row
  10. for i in range(rows):
  11. #load data from dataframe
  12. speaker = df.iloc[i, 0]
  13. transcription = df.iloc[i, 3]
  14. #loads onset and offset and converts from milliseconds to seconds
  15. onset = df.iloc[i,5]/1000
  16. offset = df.iloc[i, 1]/1000
  17. #checks if tier already exists. If not, create a new tier
  18. try:
  19. aTier = grid.get_tier(speaker)
  20. except IndexError:
  21. aTier = grid.add_tier(speaker)
  22. #creates interval and adds it to the tier
  23. pr.Tier.add_interval(aTier, onset, offset, transcription, False)
  24. print(list(pr.TextGrid.get_tier_name_num(grid)))
  25. grid.to_file(r"C:\Users\Martin\Desktop\LAAC\alignment-project\outputs\converterTest.txt")