mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Don't lock collection while generating TTS
This commit is contained in:
parent
415d757cd0
commit
633d246306
3 changed files with 25 additions and 24 deletions
|
@ -29,14 +29,14 @@ service CardRenderingService {
|
||||||
rpc CompareAnswer(CompareAnswerRequest) returns (generic.String);
|
rpc CompareAnswer(CompareAnswerRequest) returns (generic.String);
|
||||||
rpc ExtractClozeForTyping(ExtractClozeForTypingRequest)
|
rpc ExtractClozeForTyping(ExtractClozeForTypingRequest)
|
||||||
returns (generic.String);
|
returns (generic.String);
|
||||||
rpc AllTtsVoices(AllTtsVoicesRequest) returns (AllTtsVoicesResponse);
|
|
||||||
rpc WriteTtsStream(WriteTtsStreamRequest) returns (generic.Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implicitly includes any of the above methods that are not listed in the
|
// Implicitly includes any of the above methods that are not listed in the
|
||||||
// backend service.
|
// backend service.
|
||||||
service BackendCardRenderingService {
|
service BackendCardRenderingService {
|
||||||
rpc StripHtml(StripHtmlRequest) returns (generic.String);
|
rpc StripHtml(StripHtmlRequest) returns (generic.String);
|
||||||
|
rpc AllTtsVoices(AllTtsVoicesRequest) returns (AllTtsVoicesResponse);
|
||||||
|
rpc WriteTtsStream(WriteTtsStreamRequest) returns (generic.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
message ExtractAvTagsRequest {
|
message ExtractAvTagsRequest {
|
||||||
|
|
|
@ -4,6 +4,8 @@ use anki_proto::card_rendering::StripHtmlRequest;
|
||||||
|
|
||||||
use crate::backend::Backend;
|
use crate::backend::Backend;
|
||||||
use crate::card_rendering::service::strip_html_proto;
|
use crate::card_rendering::service::strip_html_proto;
|
||||||
|
use crate::card_rendering::tts;
|
||||||
|
use crate::prelude::*;
|
||||||
use crate::services::BackendCardRenderingService;
|
use crate::services::BackendCardRenderingService;
|
||||||
|
|
||||||
impl BackendCardRenderingService for Backend {
|
impl BackendCardRenderingService for Backend {
|
||||||
|
@ -13,4 +15,25 @@ impl BackendCardRenderingService for Backend {
|
||||||
) -> crate::error::Result<anki_proto::generic::String> {
|
) -> crate::error::Result<anki_proto::generic::String> {
|
||||||
strip_html_proto(input)
|
strip_html_proto(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn all_tts_voices(
|
||||||
|
&self,
|
||||||
|
input: anki_proto::card_rendering::AllTtsVoicesRequest,
|
||||||
|
) -> Result<anki_proto::card_rendering::AllTtsVoicesResponse> {
|
||||||
|
tts::all_voices(input.validate)
|
||||||
|
.map(|voices| anki_proto::card_rendering::AllTtsVoicesResponse { voices })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_tts_stream(
|
||||||
|
&self,
|
||||||
|
request: anki_proto::card_rendering::WriteTtsStreamRequest,
|
||||||
|
) -> Result<()> {
|
||||||
|
tts::write_stream(
|
||||||
|
&request.path,
|
||||||
|
&request.voice_id,
|
||||||
|
request.speed,
|
||||||
|
&request.text,
|
||||||
|
)
|
||||||
|
.map(Into::into)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ use anki_proto::generic;
|
||||||
use crate::card::CardId;
|
use crate::card::CardId;
|
||||||
use crate::card_rendering::extract_av_tags;
|
use crate::card_rendering::extract_av_tags;
|
||||||
use crate::card_rendering::strip_av_tags;
|
use crate::card_rendering::strip_av_tags;
|
||||||
use crate::card_rendering::tts;
|
|
||||||
use crate::cloze::extract_cloze_for_typing;
|
use crate::cloze::extract_cloze_for_typing;
|
||||||
use crate::collection::Collection;
|
use crate::collection::Collection;
|
||||||
use crate::error::OrInvalid;
|
use crate::error::OrInvalid;
|
||||||
|
@ -167,27 +166,6 @@ impl crate::services::CardRenderingService for Collection {
|
||||||
.to_string()
|
.to_string()
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_tts_voices(
|
|
||||||
&mut self,
|
|
||||||
input: anki_proto::card_rendering::AllTtsVoicesRequest,
|
|
||||||
) -> Result<anki_proto::card_rendering::AllTtsVoicesResponse> {
|
|
||||||
tts::all_voices(input.validate)
|
|
||||||
.map(|voices| anki_proto::card_rendering::AllTtsVoicesResponse { voices })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_tts_stream(
|
|
||||||
&mut self,
|
|
||||||
request: anki_proto::card_rendering::WriteTtsStreamRequest,
|
|
||||||
) -> Result<()> {
|
|
||||||
tts::write_stream(
|
|
||||||
&request.path,
|
|
||||||
&request.voice_id,
|
|
||||||
request.speed,
|
|
||||||
&request.text,
|
|
||||||
)
|
|
||||||
.map(Into::into)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rendered_nodes_to_proto(
|
fn rendered_nodes_to_proto(
|
||||||
|
|
Loading…
Reference in a new issue