thai-talking-clock 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. thai_talking_clock-1.0.0/MANIFEST.in +6 -0
  2. thai_talking_clock-1.0.0/PKG-INFO +122 -0
  3. thai_talking_clock-1.0.0/README.md +110 -0
  4. thai_talking_clock-1.0.0/example.py +33 -0
  5. thai_talking_clock-1.0.0/mp3-thai-clock/0.mp3 +0 -0
  6. thai_talking_clock-1.0.0/mp3-thai-clock/1.mp3 +0 -0
  7. thai_talking_clock-1.0.0/mp3-thai-clock/10.mp3 +0 -0
  8. thai_talking_clock-1.0.0/mp3-thai-clock/11.mp3 +0 -0
  9. thai_talking_clock-1.0.0/mp3-thai-clock/12.mp3 +0 -0
  10. thai_talking_clock-1.0.0/mp3-thai-clock/13.mp3 +0 -0
  11. thai_talking_clock-1.0.0/mp3-thai-clock/14.mp3 +0 -0
  12. thai_talking_clock-1.0.0/mp3-thai-clock/15.mp3 +0 -0
  13. thai_talking_clock-1.0.0/mp3-thai-clock/16.mp3 +0 -0
  14. thai_talking_clock-1.0.0/mp3-thai-clock/17.mp3 +0 -0
  15. thai_talking_clock-1.0.0/mp3-thai-clock/18.mp3 +0 -0
  16. thai_talking_clock-1.0.0/mp3-thai-clock/19.mp3 +0 -0
  17. thai_talking_clock-1.0.0/mp3-thai-clock/2.mp3 +0 -0
  18. thai_talking_clock-1.0.0/mp3-thai-clock/20.mp3 +0 -0
  19. thai_talking_clock-1.0.0/mp3-thai-clock/21.mp3 +0 -0
  20. thai_talking_clock-1.0.0/mp3-thai-clock/22.mp3 +0 -0
  21. thai_talking_clock-1.0.0/mp3-thai-clock/23.mp3 +0 -0
  22. thai_talking_clock-1.0.0/mp3-thai-clock/24.mp3 +0 -0
  23. thai_talking_clock-1.0.0/mp3-thai-clock/25.mp3 +0 -0
  24. thai_talking_clock-1.0.0/mp3-thai-clock/26.mp3 +0 -0
  25. thai_talking_clock-1.0.0/mp3-thai-clock/27.mp3 +0 -0
  26. thai_talking_clock-1.0.0/mp3-thai-clock/28.mp3 +0 -0
  27. thai_talking_clock-1.0.0/mp3-thai-clock/29.mp3 +0 -0
  28. thai_talking_clock-1.0.0/mp3-thai-clock/3.mp3 +0 -0
  29. thai_talking_clock-1.0.0/mp3-thai-clock/30.mp3 +0 -0
  30. thai_talking_clock-1.0.0/mp3-thai-clock/31.mp3 +0 -0
  31. thai_talking_clock-1.0.0/mp3-thai-clock/32.mp3 +0 -0
  32. thai_talking_clock-1.0.0/mp3-thai-clock/33.mp3 +0 -0
  33. thai_talking_clock-1.0.0/mp3-thai-clock/34.mp3 +0 -0
  34. thai_talking_clock-1.0.0/mp3-thai-clock/35.mp3 +0 -0
  35. thai_talking_clock-1.0.0/mp3-thai-clock/36.mp3 +0 -0
  36. thai_talking_clock-1.0.0/mp3-thai-clock/37.mp3 +0 -0
  37. thai_talking_clock-1.0.0/mp3-thai-clock/38.mp3 +0 -0
  38. thai_talking_clock-1.0.0/mp3-thai-clock/39.mp3 +0 -0
  39. thai_talking_clock-1.0.0/mp3-thai-clock/4.mp3 +0 -0
  40. thai_talking_clock-1.0.0/mp3-thai-clock/40.mp3 +0 -0
  41. thai_talking_clock-1.0.0/mp3-thai-clock/41.mp3 +0 -0
  42. thai_talking_clock-1.0.0/mp3-thai-clock/42.mp3 +0 -0
  43. thai_talking_clock-1.0.0/mp3-thai-clock/43.mp3 +0 -0
  44. thai_talking_clock-1.0.0/mp3-thai-clock/44.mp3 +0 -0
  45. thai_talking_clock-1.0.0/mp3-thai-clock/45.mp3 +0 -0
  46. thai_talking_clock-1.0.0/mp3-thai-clock/46.mp3 +0 -0
  47. thai_talking_clock-1.0.0/mp3-thai-clock/47.mp3 +0 -0
  48. thai_talking_clock-1.0.0/mp3-thai-clock/48.mp3 +0 -0
  49. thai_talking_clock-1.0.0/mp3-thai-clock/49.mp3 +0 -0
  50. thai_talking_clock-1.0.0/mp3-thai-clock/5.mp3 +0 -0
  51. thai_talking_clock-1.0.0/mp3-thai-clock/50.mp3 +0 -0
  52. thai_talking_clock-1.0.0/mp3-thai-clock/51.mp3 +0 -0
  53. thai_talking_clock-1.0.0/mp3-thai-clock/52.mp3 +0 -0
  54. thai_talking_clock-1.0.0/mp3-thai-clock/53.mp3 +0 -0
  55. thai_talking_clock-1.0.0/mp3-thai-clock/54.mp3 +0 -0
  56. thai_talking_clock-1.0.0/mp3-thai-clock/55.mp3 +0 -0
  57. thai_talking_clock-1.0.0/mp3-thai-clock/56.mp3 +0 -0
  58. thai_talking_clock-1.0.0/mp3-thai-clock/57.mp3 +0 -0
  59. thai_talking_clock-1.0.0/mp3-thai-clock/58.mp3 +0 -0
  60. thai_talking_clock-1.0.0/mp3-thai-clock/59.mp3 +0 -0
  61. thai_talking_clock-1.0.0/mp3-thai-clock/6.mp3 +0 -0
  62. thai_talking_clock-1.0.0/mp3-thai-clock/7.mp3 +0 -0
  63. thai_talking_clock-1.0.0/mp3-thai-clock/8.mp3 +0 -0
  64. thai_talking_clock-1.0.0/mp3-thai-clock/9.mp3 +0 -0
  65. thai_talking_clock-1.0.0/mp3-thai-clock/begintime.mp3 +0 -0
  66. thai_talking_clock-1.0.0/mp3-thai-clock/endtime.mp3 +0 -0
  67. thai_talking_clock-1.0.0/mp3-thai-clock/hour.mp3 +0 -0
  68. thai_talking_clock-1.0.0/mp3-thai-clock/minute.mp3 +0 -0
  69. thai_talking_clock-1.0.0/mp3-thai-clock/second.mp3 +0 -0
  70. thai_talking_clock-1.0.0/pyproject.toml +31 -0
  71. thai_talking_clock-1.0.0/setup.cfg +4 -0
  72. thai_talking_clock-1.0.0/talking_clock/__init__.py +35 -0
  73. thai_talking_clock-1.0.0/talking_clock/clock.py +198 -0
  74. thai_talking_clock-1.0.0/talking_clock/exceptions.py +17 -0
  75. thai_talking_clock-1.0.0/talking_clock/player.py +320 -0
  76. thai_talking_clock-1.0.0/test_talking_clock.py +154 -0
  77. thai_talking_clock-1.0.0/tests/test_clock.py +113 -0
  78. thai_talking_clock-1.0.0/tests/test_player.py +109 -0
  79. thai_talking_clock-1.0.0/thai_talking_clock.egg-info/PKG-INFO +122 -0
  80. thai_talking_clock-1.0.0/thai_talking_clock.egg-info/SOURCES.txt +81 -0
  81. thai_talking_clock-1.0.0/thai_talking_clock.egg-info/dependency_links.txt +1 -0
  82. thai_talking_clock-1.0.0/thai_talking_clock.egg-info/entry_points.txt +3 -0
  83. thai_talking_clock-1.0.0/thai_talking_clock.egg-info/top_level.txt +2 -0
@@ -0,0 +1,6 @@
1
+ graft mp3-thai-clock
2
+ include README.md
3
+ include pyproject.toml
4
+ include test_talking_clock.py
5
+ include example.py
6
+ recursive-include talking_clock *.py
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: thai-talking-clock
3
+ Version: 1.0.0
4
+ Summary: A cross-platform Python library for audio time announcement using MP3 files.
5
+ Author: Billy
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Thai Talking Clock Python Library (`thai-talking-clock`)
14
+
15
+ A cross-platform Python library and test suite for a **Talking Clock** that evaluates time as integer hours, minutes, and seconds, builds the corresponding MP3 playback sequence, and auto-detects system commands to play audio on **macOS**, **Linux**, and **Windows**.
16
+
17
+ ```bash
18
+ pip install thai-talking-clock
19
+ ```
20
+
21
+ ---
22
+
23
+ ## 🎵 How It Works
24
+
25
+ 1. Evaluates hour, minute, and second as integers (e.g. `09:05:07` -> `hour = 9`, `minute = 5`, `second = 7`).
26
+ 2. Generates the exact MP3 playback sequence using the pattern:
27
+ $$\text{begintime.mp3} \rightarrow \text{\{hour\}.mp3} \rightarrow \text{hour.mp3} \rightarrow \text{\{minute\}.mp3} \rightarrow \text{minute.mp3} \rightarrow \text{\{second\}.mp3} \rightarrow \text{second.mp3} \rightarrow \text{endtime.mp3}$$
28
+
29
+ **Example for `09:05:07`:**
30
+ `begintime.mp3` $\rightarrow$ `9.mp3` $\rightarrow$ `hour.mp3` $\rightarrow$ `5.mp3` $\rightarrow$ `minute.mp3` $\rightarrow$ `7.mp3` $\rightarrow$ `second.mp3` $\rightarrow$ `endtime.mp3`
31
+
32
+ 3. Auto-detects available system audio players across OS platforms using `shutil.which`.
33
+
34
+ ---
35
+
36
+ ## 💻 Supported OS Audio Players
37
+
38
+ | Operating System | Supported System Commands (in auto-detection priority) |
39
+ | :--- | :--- |
40
+ | **macOS (`darwin`)** | `afplay` (native), `ffplay`, `mpv`, `vlc`, `cvlc` |
41
+ | **Linux** | `play` (SoX), `paplay` (PulseAudio), `mpg123`, `mpg321`, `ffplay`, `mpv`, `cvlc`, `vlc`, `aplay` |
42
+ | **Windows (`win32` / `nt`)** | `powershell` (WMPlayer COM / SoundPlayer), `cmd` (`cmd /c start /wait`), `wmplayer`, `ffplay`, `mpv`, `vlc` |
43
+
44
+ ---
45
+
46
+ ## 📁 Repository Structure
47
+
48
+ ```
49
+ talking-clock/
50
+ ├── mp3-thai-clock/ # 65 MP3 files (0.mp3 - 59.mp3, begintime.mp3, endtime.mp3, hour.mp3, minute.mp3, second.mp3)
51
+ ├── talking_clock/ # Core Python Library Package
52
+ │ ├── __init__.py # Package export and convenience function
53
+ │ ├── clock.py # TalkingClock class (time sequence builder & audio trigger)
54
+ │ ├── player.py # SystemAudioPlayer class (cross-platform OS player detector)
55
+ │ └── exceptions.py # Custom exception classes
56
+ ├── tests/ # Automated unit tests
57
+ │ ├── test_clock.py # Unit tests for clock sequence & pattern verification
58
+ │ └── test_player.py # Unit tests for OS player detection & mock execution
59
+ ├── test_talking_clock.py# Main CLI test runner & interactive test tool
60
+ ├── example.py # Simple code example
61
+ └── pyproject.toml # Python packaging definition
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 🚀 Quick Usage
67
+
68
+ ### Python Code Usage
69
+
70
+ ```python
71
+ from talking_clock import TalkingClock, announce_current_time
72
+
73
+ # 1. Announce current system time immediately
74
+ announce_current_time()
75
+
76
+ # 2. Or instantiate TalkingClock for custom time announcements
77
+ clock = TalkingClock(mp3_dir="mp3-thai-clock")
78
+
79
+ # Get audio file sequence for 09:05:07
80
+ seq = clock.get_sequence_for_time(hour=9, minute=5, second=7)
81
+ print(seq)
82
+
83
+ # Play audio for 09:05:07
84
+ clock.announce_time(hour=9, minute=5, second=7)
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 🧪 Running Tests & Command-Line Options
90
+
91
+ Run the test suite and CLI runner using `test_talking_clock.py`:
92
+
93
+ ```bash
94
+ # 1. Run all unit tests and test example 09:05:07 time announcement:
95
+ python3 test_talking_clock.py
96
+
97
+ # 2. Run unit tests only:
98
+ python3 test_talking_clock.py --unit
99
+
100
+ # 3. Dry-run test for specific time (09:05:07):
101
+ python3 test_talking_clock.py --time 09:05:07 --dry-run
102
+
103
+ # 4. List detected system audio player & OS candidates:
104
+ python3 test_talking_clock.py --list-players
105
+
106
+ # 5. Verify all 65 required MP3 files exist in mp3-thai-clock:
107
+ python3 test_talking_clock.py --verify
108
+
109
+ # 6. Announce current system time:
110
+ python3 test_talking_clock.py --now
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 📜 Audio Licensing & Commercial Use
116
+
117
+ > [!NOTE]
118
+ > The MP3 voice audio files located in the `mp3-thai-clock/` directory were generated using **Microsoft Azure Text-to-Speech (Azure Cognitive Services Speech)** using a free subscription token from an Azure subscription.
119
+ >
120
+ > - **Licensing & Commercial Use**: Audio assets synthesized via Azure Text-to-Speech are subject to the [Microsoft Azure Legal Terms](https://azure.microsoft.com/en-us/support/legal/) and [Azure Cognitive Services Terms](https://azure.microsoft.com/en-us/support/legal/cognitive-services-terms/).
121
+ > - If you plan to use this library or the provided audio files for commercial purposes, please ensure your usage aligns with Microsoft Azure's licensing guidelines or replace the MP3 files with your own custom or commercially licensed voice samples.
122
+
@@ -0,0 +1,110 @@
1
+ # Thai Talking Clock Python Library (`thai-talking-clock`)
2
+
3
+ A cross-platform Python library and test suite for a **Talking Clock** that evaluates time as integer hours, minutes, and seconds, builds the corresponding MP3 playback sequence, and auto-detects system commands to play audio on **macOS**, **Linux**, and **Windows**.
4
+
5
+ ```bash
6
+ pip install thai-talking-clock
7
+ ```
8
+
9
+ ---
10
+
11
+ ## 🎵 How It Works
12
+
13
+ 1. Evaluates hour, minute, and second as integers (e.g. `09:05:07` -> `hour = 9`, `minute = 5`, `second = 7`).
14
+ 2. Generates the exact MP3 playback sequence using the pattern:
15
+ $$\text{begintime.mp3} \rightarrow \text{\{hour\}.mp3} \rightarrow \text{hour.mp3} \rightarrow \text{\{minute\}.mp3} \rightarrow \text{minute.mp3} \rightarrow \text{\{second\}.mp3} \rightarrow \text{second.mp3} \rightarrow \text{endtime.mp3}$$
16
+
17
+ **Example for `09:05:07`:**
18
+ `begintime.mp3` $\rightarrow$ `9.mp3` $\rightarrow$ `hour.mp3` $\rightarrow$ `5.mp3` $\rightarrow$ `minute.mp3` $\rightarrow$ `7.mp3` $\rightarrow$ `second.mp3` $\rightarrow$ `endtime.mp3`
19
+
20
+ 3. Auto-detects available system audio players across OS platforms using `shutil.which`.
21
+
22
+ ---
23
+
24
+ ## 💻 Supported OS Audio Players
25
+
26
+ | Operating System | Supported System Commands (in auto-detection priority) |
27
+ | :--- | :--- |
28
+ | **macOS (`darwin`)** | `afplay` (native), `ffplay`, `mpv`, `vlc`, `cvlc` |
29
+ | **Linux** | `play` (SoX), `paplay` (PulseAudio), `mpg123`, `mpg321`, `ffplay`, `mpv`, `cvlc`, `vlc`, `aplay` |
30
+ | **Windows (`win32` / `nt`)** | `powershell` (WMPlayer COM / SoundPlayer), `cmd` (`cmd /c start /wait`), `wmplayer`, `ffplay`, `mpv`, `vlc` |
31
+
32
+ ---
33
+
34
+ ## 📁 Repository Structure
35
+
36
+ ```
37
+ talking-clock/
38
+ ├── mp3-thai-clock/ # 65 MP3 files (0.mp3 - 59.mp3, begintime.mp3, endtime.mp3, hour.mp3, minute.mp3, second.mp3)
39
+ ├── talking_clock/ # Core Python Library Package
40
+ │ ├── __init__.py # Package export and convenience function
41
+ │ ├── clock.py # TalkingClock class (time sequence builder & audio trigger)
42
+ │ ├── player.py # SystemAudioPlayer class (cross-platform OS player detector)
43
+ │ └── exceptions.py # Custom exception classes
44
+ ├── tests/ # Automated unit tests
45
+ │ ├── test_clock.py # Unit tests for clock sequence & pattern verification
46
+ │ └── test_player.py # Unit tests for OS player detection & mock execution
47
+ ├── test_talking_clock.py# Main CLI test runner & interactive test tool
48
+ ├── example.py # Simple code example
49
+ └── pyproject.toml # Python packaging definition
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 🚀 Quick Usage
55
+
56
+ ### Python Code Usage
57
+
58
+ ```python
59
+ from talking_clock import TalkingClock, announce_current_time
60
+
61
+ # 1. Announce current system time immediately
62
+ announce_current_time()
63
+
64
+ # 2. Or instantiate TalkingClock for custom time announcements
65
+ clock = TalkingClock(mp3_dir="mp3-thai-clock")
66
+
67
+ # Get audio file sequence for 09:05:07
68
+ seq = clock.get_sequence_for_time(hour=9, minute=5, second=7)
69
+ print(seq)
70
+
71
+ # Play audio for 09:05:07
72
+ clock.announce_time(hour=9, minute=5, second=7)
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🧪 Running Tests & Command-Line Options
78
+
79
+ Run the test suite and CLI runner using `test_talking_clock.py`:
80
+
81
+ ```bash
82
+ # 1. Run all unit tests and test example 09:05:07 time announcement:
83
+ python3 test_talking_clock.py
84
+
85
+ # 2. Run unit tests only:
86
+ python3 test_talking_clock.py --unit
87
+
88
+ # 3. Dry-run test for specific time (09:05:07):
89
+ python3 test_talking_clock.py --time 09:05:07 --dry-run
90
+
91
+ # 4. List detected system audio player & OS candidates:
92
+ python3 test_talking_clock.py --list-players
93
+
94
+ # 5. Verify all 65 required MP3 files exist in mp3-thai-clock:
95
+ python3 test_talking_clock.py --verify
96
+
97
+ # 6. Announce current system time:
98
+ python3 test_talking_clock.py --now
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 📜 Audio Licensing & Commercial Use
104
+
105
+ > [!NOTE]
106
+ > The MP3 voice audio files located in the `mp3-thai-clock/` directory were generated using **Microsoft Azure Text-to-Speech (Azure Cognitive Services Speech)** using a free subscription token from an Azure subscription.
107
+ >
108
+ > - **Licensing & Commercial Use**: Audio assets synthesized via Azure Text-to-Speech are subject to the [Microsoft Azure Legal Terms](https://azure.microsoft.com/en-us/support/legal/) and [Azure Cognitive Services Terms](https://azure.microsoft.com/en-us/support/legal/cognitive-services-terms/).
109
+ > - If you plan to use this library or the provided audio files for commercial purposes, please ensure your usage aligns with Microsoft Azure's licensing guidelines or replace the MP3 files with your own custom or commercially licensed voice samples.
110
+
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env python3
2
+ """Example script showing how to use the talking_clock Python library."""
3
+
4
+ from talking_clock import TalkingClock, SystemAudioPlayer, announce_current_time
5
+
6
+ def main():
7
+ print("--- Talking Clock Library Usage Example ---\n")
8
+
9
+ # 1. Quick convenience function to announce current time:
10
+ # announce_current_time()
11
+
12
+ # 2. Instantiate clock with auto-detected player:
13
+ clock = TalkingClock(mp3_dir="mp3-thai-clock")
14
+
15
+ # Display detected player info:
16
+ player_info = clock.player.detected_player
17
+ print(f"Detected OS Audio Player: {player_info['name']} ({player_info['binary']})")
18
+
19
+ # 3. Generate MP3 sequence for 09:05:07
20
+ h, m, s = 9, 5, 7
21
+ seq = clock.get_sequence_for_time(h, m, s)
22
+
23
+ print(f"\nSequence for {h:02d}:{m:02d}:{s:02d}:")
24
+ for f in seq:
25
+ print(f" - {f}")
26
+
27
+ # 4. Announce custom time
28
+ print("\nAnnouncing 09:05:07...")
29
+ clock.announce_time(hour=9, minute=5, second=7, blocking=True)
30
+ print("Done!")
31
+
32
+ if __name__ == "__main__":
33
+ main()
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "thai-talking-clock"
7
+ version = "1.0.0"
8
+ description = "A cross-platform Python library for audio time announcement using MP3 files."
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ authors = [
12
+ { name = "Billy" }
13
+ ]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: MacOS",
17
+ "Operating System :: POSIX :: Linux",
18
+ "Operating System :: Microsoft :: Windows",
19
+ ]
20
+ dependencies = []
21
+
22
+ [project.scripts]
23
+ thai-talking-clock = "test_talking_clock:main"
24
+ talking-clock = "test_talking_clock:main"
25
+
26
+ [tool.setuptools]
27
+ packages = ["talking_clock", "mp3-thai-clock"]
28
+
29
+ [tool.setuptools.package-data]
30
+ "*" = ["*.mp3"]
31
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,35 @@
1
+ """Talking Clock package.
2
+
3
+ A cross-platform Python library for audio time announcement.
4
+ """
5
+
6
+ from .clock import TalkingClock
7
+ from .player import SystemAudioPlayer
8
+ from .exceptions import (
9
+ TalkingClockError,
10
+ AudioPlayerNotFoundError,
11
+ AudioPlaybackError,
12
+ MissingAudioFileError,
13
+ )
14
+
15
+ __version__ = "1.0.0"
16
+
17
+ __all__ = [
18
+ "TalkingClock",
19
+ "SystemAudioPlayer",
20
+ "TalkingClockError",
21
+ "AudioPlayerNotFoundError",
22
+ "AudioPlaybackError",
23
+ "MissingAudioFileError",
24
+ ]
25
+
26
+
27
+ def announce_current_time(
28
+ mp3_dir: str = None,
29
+ preferred_player: str = None,
30
+ blocking: bool = True,
31
+ ):
32
+ """Convenience function to announce the current system time immediately."""
33
+ player = SystemAudioPlayer(preferred_player=preferred_player)
34
+ clock = TalkingClock(mp3_dir=mp3_dir, player=player)
35
+ return clock.announce_time(blocking=blocking)