Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note type of New sync changes to "Yanki - Basic (and reversed card with extra)"? #9

Closed
emisjerry opened this issue Aug 16, 2024 · 12 comments
Assignees
Labels
question Further information is requested

Comments

@emisjerry
Copy link

emisjerry commented Aug 16, 2024

Hi,

The note type changes to "Yanki - Basic (and reversed card with extra)", not "Yanki - Basic (and reversed card)" as usual.

"Yanki - Basic (and reversed card with extra)" will replace the original ""Yanki - Basic (and reversed card)"?

There's an Extra field in this note type. How can i edit Extra in my Obsidian?

@kitschpatrol
Copy link
Owner

Yes this is a change in note type —  Yanki - Basic (and reversed card with extra) is a superset of the old Yanki - Basic (and reversed card), so it's now used exclusively.

The extra field is inferred from the Obsidian Markdown as follows:

Front: Sometimes the answer is the question

---

---

Back: Sometimes the question is the answer

---

Extra: This will appear on the back of both generated cards

(The readme was also updated.)

@kitschpatrol
Copy link
Owner

kitschpatrol commented Aug 16, 2024

Just added a few more details to the readme. I should set up a changelog at some point as well.

@emisjerry
Copy link
Author

Thanks fore your reply.

@kitschpatrol kitschpatrol added the question Further information is requested label Aug 16, 2024
@kitschpatrol kitschpatrol self-assigned this Aug 16, 2024
@emisjerry
Copy link
Author

emisjerry commented Aug 16, 2024

Here's my note, it creates "Yanki - Basic (and reversed card with extra)" but i don't have the third part:

In the small town of Greenfield, there was a popular animal show every year.

---

---

在Greenfield的小鎮上,每年都有一個受歡迎的動物展。

@kitschpatrol
Copy link
Owner

kitschpatrol commented Aug 16, 2024

Yes, this is currently functioning as intended.

Since the Extra field is rendered conditionally in the card template, the new Yanki - Basic (and reversed card with extra) type is a clean superset of the previous Yanki - Basic (and reversed card) type, which is why it's now used for all reversed cards.

This issue of model type migration across Yanki versions is subtly tricky. Here are some assorted points explaining my current reasoning:

  • The fewer Yanki-generated model types, the better. (This is a matter of opinion, but it's fewer code paths, less clutter in the user's Anki database. And the "extra" feature feels like a logical extension of the reversed model type, not a distinct thing.)
  • From a technical standpoint, it's easier / faster / safer to have Yanki create a new card type with new functionality than it is to modify existing types in-place. This avoids an explicit model migration step in the code, and instead, on the next sync, migrations happen implicitly when Yanki infers the "updated" type based on the Markdown it parses and updates the model type associated with a note if necessary. (I tested ahead-of-time to confirm that card review stats are preserved across this process.)
  • Model types can't have the same name, which is why the updated reversed type has a different name. Maybe Yanki - Basic (and reversed card with optional extra) would have been better. I find the model names a bit weird and verbose in general, but was trying to maintain consistency with Anki's default model type names.
  • I considered this a "minor" / non-breaking change from a semver standpoint because it should be transparent to the user except in very rare instances where there's already a trailing --- in a reversed note. (Related to semver, I have some concerns about how Obsidian doesn't flag major and potentially breaking version increments during the in-app Community Plugin update process, but that's for another day...)
  • Yanki "owns" both the cards and the model types it creates, and I try to explain in the readme that they should not be edited or used independently of Yanki at the risk of being overwritten during synchronization — but I think I need to make this point even more prominent
  • A later version of Yanki might include a post-sync clean-up step to remove deprecated Yanki model types with no note instances, but I didn't do that in the latest release out of an excess of caution.
  • I don't anticipate too many more changes to the model types other than what's being discussed in issue More Basic (and reversed card)  #5, and if there are any changes they will be "supersets" that add to rather than change the existing mappings between Markdown syntax and Anki types. In general, users who need to customize note types would be better served by some of the other Obsidian+Anki plugin options.

I hope that clears up what's going on a bit, but if you have more questions feel free.

@kitschpatrol kitschpatrol reopened this Aug 16, 2024
@emisjerry
Copy link
Author

Will there be a "Yanki - Basic (and Extra)" note type? For example, i can put "winner" to Extra field for AwesomeTTS to play the audio. The "Yanki - Basic (and reversed card with extra)" hadles perfectly.

# winner
KK\[ˋwɪnɚ] 

---

n. 獲勝者,優勝者 

---

winner

@emisjerry
Copy link
Author

emisjerry commented Aug 16, 2024

In my "Yanki - Basic (and reversed card with extra)" type, i use the following Front template.
If the note has Extra content, uses Extra to pronounce, otherwise uses Front field.

{{Front}}
<br>
{{#Extra}}
{{tts en_US voices=AwesomeTTS:Extra}}
{{/Extra}}

{{^Extra}}
{{tts en_US voices=AwesomeTTS:Front}}
{{/Extra}}

@kitschpatrol
Copy link
Owner

Hi Jerry, I didn't add "Extra" support to the basic type because I couldn't see a use for it, and because it would potentially conflict with the Markdown syntax proposed in #5.

I definitely see the utility of TTS in flashcards general... but one thing I'm going for with Yanki is the idea that your flashcards are as complete and as useful in Obsidian as they are in Anki, which points towards implementing things like TTS in the Obsidian layer instead of the Anki layer.

Ideally, you'd have something like this in Obsidian, where winner.mp3 is the TTS audio clip:

# winner
KK\[ˋwɪnɚ] 

![[winner.mp3]]

---

n. 獲勝者,優勝者 

This would let you play the audio in Obsidian at will, and the audio would also play automatically once synced to Anki without requiring any template customization. (And again in general I don't think I can support template customization in Anki since Yanki depends on control over its templates for consistent behavior.)

So then the problem would be how to generate the winner.mp3 dynamically in Obsidian, and after a quick investigation I have to say the options for TTS Plugins in Obsidian are slightly underwhelming. This approach on YouTube is kind of interesting, but probably too technical.

If generating the audio in Obsidian is too tricky, then maybe there's a solution that would work but doesn't require template customization — maybe we could appropriate some existing Markdown syntax to indicate text to treat as TTS in Anki, or maybe there's a frontmatter / property flag to indicate that a field should be read aloud...

I will leave this thread open and keep thinking about it.

@emisjerry
Copy link
Author

Single audio file can be solved by this way. But it won't work if i have a sentence. for example:

In the small town of Greenfield, there was a popular animal show every year.

---

---

在格林菲爾德的小鎮上,每年都有一個受歡迎的動物展。

By using TTS method it will have two benefits at least:

  1. Sentences or an article can be pronounced by TTS engin
  2. there's no audio file downloaded in local collection.media folder

I can accept that “Yanki - Basic” doesn't provide an Extra field, because the English word usually uses the “Yanki - Basic with reversed card” note type. For example:

# zebra
KK\[ˋzibrə] 

---
---

n. 【動】斑馬\[C] 

---

zebra

@emisjerry
Copy link
Author

BTW, i have a new YouTube video for generating notes from an article, by using Copilot (ChatGPT), Note Splitter and Yanki plugins:

https://youtu.be/Gu6B7nqUV9o

Perhaps you could take the time to browse around and see what I'm looking for.

I think the Extra field adds a lot of flexibility to Yanki, and should have more application possibilities. Thank you for your efforts.

@kitschpatrol
Copy link
Owner

Thanks! Added a link to your latest video to the readme.

Regarding your two points about TTS, they make sense but I would just point out that if there was something similar to AwesomeTTS that worked in Obsidian instead of Anki, then:

  • I'd assume it could transcribe either sentences or single words.
  • Any Obsidian-generated audio files would be managed automatically, because, by default, Yanki syncs any local file attachments in Obsidian to the media collection storage in Anki.

Just trying to think of a good way to support this that doesn't require modifying the Yanki-generated note type templates in Anki.

@kitschpatrol kitschpatrol changed the title [Question] Note type of New sync changes to "Yanki - Basic (and reversed card with extra)"? Note type of New sync changes to "Yanki - Basic (and reversed card with extra)"? Sep 1, 2024
@kitschpatrol
Copy link
Owner

I can't think of a generic way to support the "TTS in extra field" use-case in Yanki, and still think it would be best to do it in Obsidian instead of Anki. (Some kind of Templater script to automate generating TTS audio clips which Yanki could then automatically sync to and play in Anki would likely be the most accessible approach.)

I'm going to close this issue since the original note type question has been addressed, but if the field customization / TTS part is still a major concern please open a new issue specific to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants