diff --git a/README.md b/README.md index 74311f8..5f9db7e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,11 @@ Plugin for [Obsidian](https://obsidian.md) ![GitHub](https://img.shields.io/github/license/joethei/obsidian-tts) [![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com) --- -**This plugin is currently in beta** +Features: +- Start playback for note from statusbar and ribbon +- Only speaking selected text in edit mode: +![Selection Demo](https://i.joethei.space/Obsidian_rjttPsYPwj.png) +- usable with other plugins (currently [RSS Reader](https://github.com/joethei/obsidian-rss)) You can create language specific voices, which will be used when you have a note with ```lang: {languageCode}``` @@ -20,7 +24,6 @@ to [this bug in the Webview](https://bugs.chromium.org/p/chromium/issues/detail? ## Adding languages This plugin uses the native API of your Operating System, to add a new language reference the documentation accordingly: - - [Windows 10](https://support.microsoft.com/en-us/topic/how-to-download-text-to-speech-languages-for-windows-10-d5a6b612-b3ae-423f-afa5-4f6caf1ec5d3) - [MacOS](https://support.apple.com/guide/mac-help/change-the-system-language-mh26684/mac) - [iOS](https://support.apple.com/guide/iphone/change-the-language-and-region-iphce20717a3/ios) @@ -29,8 +32,7 @@ This plugin uses the native API of your Operating System, to add a new language ## Installing the plugin - - +- `Settings > Third-party plugins > Community Plugins > Browse` and search for `Text to Speech` - Using the [Beta Reviewers Auto-update Tester](https://github.com/TfTHacker/obsidian42-brat) plugin with the repo path: `joethei/obsidian-tts` - Copy over `main.js`, `styles.css`, `manifest.json` from the releases to your diff --git a/manifest.json b/manifest.json index 7a18e5d..cb4ba52 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-tts", "name": "Text to Speech", - "version": "0.3.2", + "version": "0.3.3", "minAppVersion": "0.12.0", "description": "Text to speech for Obsidian. Hear your notes.", "author": "Johannes Theiner", diff --git a/package.json b/package.json index 82e4770..1fcf519 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-tts", - "version": "0.3.2", + "version": "0.3.3", "description": "Text to speech for Obsidian. Hear your notes.", "main": "main.js", "scripts": { diff --git a/src/TTSService.ts b/src/TTSService.ts index 233abcb..0a91a2b 100644 --- a/src/TTSService.ts +++ b/src/TTSService.ts @@ -10,25 +10,25 @@ export class TTSService { } stop(): void { - if(!this.isSpeaking()) return; + if (!this.isSpeaking()) return; window.speechSynthesis.cancel(); } pause(): void { - if(!this.isSpeaking()) return; + if (!this.isSpeaking()) return; window.speechSynthesis.pause(); } resume(): void { - if(!this.isSpeaking()) return; + if (!this.isSpeaking()) return; window.speechSynthesis.resume(); } - isSpeaking() : boolean { + isSpeaking(): boolean { return window.speechSynthesis.speaking; } - isPaused() : boolean { + isPaused(): boolean { return window.speechSynthesis.paused; } @@ -49,7 +49,12 @@ export class TTSService { } if (this.plugin.settings.speakTitle) { - content = title + " " + content; + content = title + " ! ! " + content; + } + + if (!this.plugin.settings.speakEmoji) { + //regex from https://ihateregex.io/expr/emoji/ + content = content.replace(/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g, ''); } //add pauses, taken from https://stackoverflow.com/a/50944593/5589264 @@ -94,7 +99,7 @@ export class TTSService { async play(view: MarkdownView): Promise { let content = view.getViewData(); - let language = this.getLanguageFromFrontmatter(view); + const language = this.getLanguageFromFrontmatter(view); if (!this.plugin.settings.speakFrontmatter) if (content.startsWith("---")) { @@ -106,10 +111,10 @@ export class TTSService { } - getLanguageFromFrontmatter(view: MarkdownView) : string { + getLanguageFromFrontmatter(view: MarkdownView): string { let language = ""; //check if any language is defined in frontmatter - if(!view.getViewData().startsWith("---")) return language; + if (!view.getViewData().startsWith("---")) return language; const frontmatter = view.getViewData().match(/---[\s\S]*?---/); if (frontmatter && frontmatter[0]) { diff --git a/src/main.ts b/src/main.ts index fadb9fc..f8e33c7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,7 +27,7 @@ export default class TTSPlugin extends Plugin { this.addCommand({ id: 'start-tts-playback', name: 'Start playback', - editorCallback: (editor, view) => { + editorCallback: (_, view) => { this.ttsService.play(view); } }); diff --git a/src/settings.ts b/src/settings.ts index c4d9e77..d1f7983 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -18,6 +18,7 @@ export interface TTSSettings { speakSyntax: boolean; speakCodeblocks: boolean; speakTitle: boolean; + speakEmoji: boolean; languageVoices: LanguageVoiceMap[]; stopPlaybackWhenNoteChanges: boolean; } @@ -32,6 +33,7 @@ export const DEFAULT_SETTINGS: TTSSettings = { speakSyntax: false, speakTitle: true, speakCodeblocks: false, + speakEmoji: false, languageVoices: [], stopPlaybackWhenNoteChanges: false, } @@ -272,6 +274,17 @@ export class TTSSettingsTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName("Emoji") + .addToggle(async (toggle) => { + toggle + .setValue(this.plugin.settings.speakEmoji) + .onChange(async (value) => { + this.plugin.settings.speakEmoji = value; + await this.plugin.saveSettings(); + }); + }); + containerEl.createEl("h2", {text: "Misc"}); new Setting(containerEl) .setName("Stop playback when a note is closed/new note is opened") diff --git a/versions.json b/versions.json index 697d237..132a75b 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,6 @@ { "0.1.0": "0.9.12", "0.2.0": "0.9.12", - "0.3.2": "0.12.0" + "0.3.2": "0.12.0", + "0.3.3": "0.12.0" }