Update import statement in local-duckduckgo.ts, prompt.tsx, wxt.config.ts, webui.tsx, PlaygroundChat.tsx, other.tsx, Markdown.tsx, and useMessageOption.tsx
This commit is contained in:
20
src/utils/markdown-to-ssml.ts
Normal file
20
src/utils/markdown-to-ssml.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export function markdownToSSML(markdown: string): string {
|
||||
let ssml = markdown.replace(/\\n/g, "<break/>")
|
||||
|
||||
ssml = ssml.replace(
|
||||
/^(#{1,6}) (.*?)(?=\r?\n\s*?(?:\r?\n|$))/gm,
|
||||
(match, hashes, heading) => {
|
||||
const level = hashes.length
|
||||
const rate = (level - 1) * 10 + 100
|
||||
return `<prosody rate="${rate}%">${heading}</prosody>`
|
||||
}
|
||||
)
|
||||
|
||||
ssml = ssml.replace(/\\\*\\\*(.\*?)\\\*\\\*/g, "<emphasis>$1</emphasis>")
|
||||
ssml = ssml.replace(
|
||||
/\\\*(.\*?)\\\*/g,
|
||||
'<amazon:effect name="whispered">$1</amazon:effect>'
|
||||
)
|
||||
ssml = `<speak>${ssml}</speak>`
|
||||
return `<?xml version="1.0"?>${ssml}`
|
||||
}
|
||||
Reference in New Issue
Block a user