Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

say_numbers_prompt.py 1.9 KB

You have to be logged in to leave a comment. Sign In
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  1. from __future__ import print_function
  2. import time
  3. import math
  4. """
  5. Prompts you to say numbers.
  6. Start this, and then hit "Record" in Audacity.
  7. http://www.audacityteam.org/download/
  8. When you start Audacity, look in the bottom-left and set the Project Rate (Hz) to 8000.
  9. It takes about 30 minutes to record a full dataset.
  10. Tips:
  11. - Turn off your screen saver before you start!
  12. - Try a short recording session first to make sure everything works OK before doing the full recording.
  13. When done, export the audio as one big .wav file and use 'split_and_label_numbers.py'
  14. to make the labeled dataset.
  15. """
  16. DELAY_BETWEEN_NUMBERS = 3
  17. REPEATS_PER_NUMBER = 3
  18. def wait_until(t):
  19. while time.time() < t:
  20. time.sleep(0.01)
  21. def generate_number_sequence():
  22. # We want the numbers jumbled up (helps eliminate any previous-number effects)
  23. # This function scrambles the numbers in a deterministic way so that we can remember
  24. # what the order was later.
  25. # A deterministic shuffle makes labeling easy, makes pausing / resuming the experiment easy, etc.
  26. nums = [str(i) for i in range(10) for set_num in range(REPEATS_PER_NUMBER)]
  27. for i in range(len(nums)):
  28. target = int(round(math.pi * i)) % len(nums)
  29. (nums[i], nums[target]) = (nums[target], nums[i])
  30. return nums
  31. def show_numbers():
  32. nums = generate_number_sequence()
  33. print("Get ready...")
  34. time.sleep(1)
  35. t_start = time.time()
  36. for i, num in enumerate(nums):
  37. if (float(i)/len(nums) * 100) % 10 == 0:
  38. print("\n====", float(i)/len(nums)*100, "% done====\n")
  39. else:
  40. print("")
  41. t_next_display = t_start + (i + 1) * DELAY_BETWEEN_NUMBERS
  42. t_next_blank = t_next_display + 2.5
  43. # display a number
  44. wait_until(t_next_display)
  45. print(num)
  46. # blank
  47. wait_until(t_next_blank)
  48. if __name__ == '__main__':
  49. show_numbers()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...