Skip to content

Commit 89e957b

Browse files
committed
build(CI): add CI GitHub Action script
1 parent f7969ea commit 89e957b

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Swift Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: macOS-12
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Build
17+
run: swift build
18+
19+
- name: Run test
20+
run: swift test

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let package = Package(
77
name: "swift-tts",
88
platforms: [
99
.iOS(.v15),
10-
.macOS(.v13),
10+
.macOS(.v12),
1111
],
1212
products: [
1313
.library(name: "SwiftTTS", targets: ["SwiftTTS"]),

Sources/SwiftTTS/SwiftTTS.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,29 @@ private final class Engine: NSObject, AVSpeechSynthesizerDelegate {
8585
}
8686

8787
public extension SwiftTTS {
88-
static let live = {
88+
static var live: Self {
8989
let engine = Engine(rateRatio: 1.0, voice: AVSpeechSynthesisVoice(language: "en-GB"))
9090

9191
let isSpeaking = AsyncStream { continuation in
92-
engine.isSpeaking = { continuation.yield($0) }
92+
engine.isSpeaking = {
93+
if $0 {
94+
continuation.yield(true)
95+
} else {
96+
continuation.yield(false)
97+
continuation.finish()
98+
}
99+
}
93100
}
94101

95102
let speakingProgress = AsyncStream { continuation in
96-
engine.speakingProgress = { continuation.yield($0) }
103+
engine.speakingProgress = {
104+
if $0 < 1.0 {
105+
continuation.yield($0)
106+
} else {
107+
continuation.yield(1)
108+
continuation.finish()
109+
}
110+
}
97111
}
98112

99113
return Self(
@@ -105,5 +119,5 @@ public extension SwiftTTS {
105119
isSpeaking: { isSpeaking },
106120
speakingProgress: { speakingProgress }
107121
)
108-
}()
122+
}
109123
}

Tests/SwiftTTSTests/SwiftTTSTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44

55
@MainActor
66
final class SwiftTTSTests: XCTestCase {
7-
func testLiveTTSWithoutCrashing() {
7+
func testLiveTTSWithoutCrashing() async {
88
let tts = SwiftTTS.live
99
tts.speak("Let's test that!")
1010
}

0 commit comments

Comments
 (0)