mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 21:47:27 +00:00
feat(ios): add Talk voice directive hint toggle (#18250)
* feat(ios): add Talk voice directive hint toggle * docs(changelog): credit voice directive hint slice --------- Co-authored-by: Mariano Belinky <mariano@mb-server-643.local>
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
public enum TalkPromptBuilder: Sendable {
|
||||
public static func build(transcript: String, interruptedAtSeconds: Double?) -> String {
|
||||
public static func build(
|
||||
transcript: String,
|
||||
interruptedAtSeconds: Double?,
|
||||
includeVoiceDirectiveHint: Bool = true
|
||||
) -> String {
|
||||
var lines: [String] = [
|
||||
"Talk Mode active. Reply in a concise, spoken tone.",
|
||||
"You may optionally prefix the response with JSON (first line) to set ElevenLabs voice (id or alias), e.g. {\"voice\":\"<id>\",\"once\":true}.",
|
||||
]
|
||||
|
||||
if includeVoiceDirectiveHint {
|
||||
lines.append(
|
||||
"You may optionally prefix the response with JSON (first line) to set ElevenLabs voice (id or alias), e.g. {\"voice\":\"<id>\",\"once\":true}."
|
||||
)
|
||||
}
|
||||
|
||||
if let interruptedAtSeconds {
|
||||
let formatted = String(format: "%.1f", interruptedAtSeconds)
|
||||
lines.append("Assistant speech interrupted at \(formatted)s.")
|
||||
|
||||
@@ -12,4 +12,18 @@ final class TalkPromptBuilderTests: XCTestCase {
|
||||
let prompt = TalkPromptBuilder.build(transcript: "Hi", interruptedAtSeconds: 1.234)
|
||||
XCTAssertTrue(prompt.contains("Assistant speech interrupted at 1.2s."))
|
||||
}
|
||||
|
||||
func testBuildIncludesVoiceDirectiveHintByDefault() {
|
||||
let prompt = TalkPromptBuilder.build(transcript: "Hello", interruptedAtSeconds: nil)
|
||||
XCTAssertTrue(prompt.contains("ElevenLabs voice"))
|
||||
}
|
||||
|
||||
func testBuildExcludesVoiceDirectiveHintWhenDisabled() {
|
||||
let prompt = TalkPromptBuilder.build(
|
||||
transcript: "Hello",
|
||||
interruptedAtSeconds: nil,
|
||||
includeVoiceDirectiveHint: false)
|
||||
XCTAssertFalse(prompt.contains("ElevenLabs voice"))
|
||||
XCTAssertTrue(prompt.contains("Talk Mode active."))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user