Spaces:
Sleeping
Sleeping
Commit
·
a58ee91
1
Parent(s):
1378e63
fixtts
Browse files- public/esltool.js +1 -1
- public/utils.js +8 -1
public/esltool.js
CHANGED
|
@@ -75,7 +75,7 @@ function getSelectedText() {
|
|
| 75 |
|
| 76 |
function ask(prompt) {
|
| 77 |
|
| 78 |
-
let currentLineString = utils.
|
| 79 |
let selectText = window.getSelection().toString();
|
| 80 |
prompt=`${prompt} **${selectText.length >= 1 ? selectText : currentLineString}** `
|
| 81 |
utils.displayMarkdown(prompt+'...');
|
|
|
|
| 75 |
|
| 76 |
function ask(prompt) {
|
| 77 |
|
| 78 |
+
let currentLineString = utils.getCurrentBlock(document.activeElement);
|
| 79 |
let selectText = window.getSelection().toString();
|
| 80 |
prompt=`${prompt} **${selectText.length >= 1 ? selectText : currentLineString}** `
|
| 81 |
utils.displayMarkdown(prompt+'...');
|
public/utils.js
CHANGED
|
@@ -252,7 +252,7 @@ const utils = {
|
|
| 252 |
}
|
| 253 |
},
|
| 254 |
tts: function synthesizeSpeech(text = 'test text', voice = 'alloy') {
|
| 255 |
-
let url = `https://tts.
|
| 256 |
|
| 257 |
let container = document.getElementById("devlent_tts_container");
|
| 258 |
if (!container) {
|
|
@@ -360,6 +360,13 @@ const utils = {
|
|
| 360 |
|
| 361 |
return currentLine;
|
| 362 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
isEditableElement: function isEditableElement(element) {
|
| 364 |
while (element) {
|
| 365 |
if (element.contentEditable === "true") {
|
|
|
|
| 252 |
}
|
| 253 |
},
|
| 254 |
tts: function synthesizeSpeech(text = 'test text', voice = 'alloy') {
|
| 255 |
+
let url = `https://im1111-free-get-tts.hf.space/tts/${encodeURIComponent(text)}`;
|
| 256 |
|
| 257 |
let container = document.getElementById("devlent_tts_container");
|
| 258 |
if (!container) {
|
|
|
|
| 360 |
|
| 361 |
return currentLine;
|
| 362 |
},
|
| 363 |
+
getCurrentBlock(elem) {
|
| 364 |
+
let text=elem.textContent;
|
| 365 |
+
const blocks = text.split(/(\n{2,})/);
|
| 366 |
+
return blocks[blocks.indexOf('\n\n') + 1];
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
,
|
| 370 |
isEditableElement: function isEditableElement(element) {
|
| 371 |
while (element) {
|
| 372 |
if (element.contentEditable === "true") {
|