-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ヘッダー行のみの場合、特殊読み上げを行う機能を追加 (#182)
* feat: ヘッダー行のみの場合、特殊読み上げを行う機能を追加 * fix: removed debug print * fix: あたらしいテキストの処理を修正 * chore: prepare for adding H1,2,3 * feat: leveled heading --------- Co-authored-by: yuua <identity@yuua.dev>
- Loading branch information
Showing
8 changed files
with
329 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
src/main/kotlin/com/jaoafa/vcspeaker/tts/processors/MarkdownFormatProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
package com.jaoafa.vcspeaker.tts.processors | ||
|
||
import com.jaoafa.vcspeaker.tts.Voice | ||
import com.jaoafa.vcspeaker.tts.markdown.LineEffect | ||
import com.jaoafa.vcspeaker.tts.markdown.toMarkdown | ||
import dev.kord.core.entity.Message | ||
|
||
class MarkdownFormatProcessor : BaseProcessor() { | ||
override val priority = 60 | ||
override val priority = 80 | ||
|
||
override suspend fun process(message: Message?, content: String, voice: Voice): Pair<String, Voice> { | ||
val markdown = content.toMarkdown().joinToString("") { it.toReadable() } | ||
val markdown = content.toMarkdown() | ||
|
||
return markdown to voice | ||
val heading = markdown.first().effects.firstOrNull { it.name.startsWith("Heading") } | ||
|
||
val newVoice = if (markdown.size == 1 && heading != null) { | ||
when (heading) { | ||
LineEffect.Heading1 -> voice.copy(speed = 200) | ||
LineEffect.Heading2 -> voice.copy(speed = 175) | ||
LineEffect.Heading3 -> voice.copy(speed = 150) | ||
else -> voice | ||
} | ||
} else voice | ||
|
||
val readableMarkdown = markdown.joinToString(" ") { it.toReadable() } | ||
|
||
return readableMarkdown to newVoice | ||
} | ||
} |
Oops, something went wrong.