l3kn / org-fc

Spaced Repetition System for Emacs org-mode
https://www.leonrische.me/fc/index.html
GNU General Public License v3.0
259 stars 31 forks source link

Keybinding to repeat audio #64

Closed lcabrini closed 1 year ago

lcabrini commented 3 years ago

I'm currently transitioning from Anki to org-fc, since I spend most of my life in Emacs already. I rely a lot of comprehension cards when I first start learning a language. The front side is an audio sample that I have to listen to and translate.

In Anki I can invoke 'R' to repeat the audio. I've looked through the org-fc documentation but not found if there is such a keybinding. Have I missed something? If there isn't, I think I could probably figure out how to add it? Would such a feature be considered?

l3kn commented 3 years ago

I'm using the vocab card type for learning languages and it has two functions to replay the audio at normal & slower speed:

(defun org-fc-type-vocab-play ()
  "Play vocab audio file at normal speed."
  (interactive)
  (org-fc-audio-play org-fc-type-vocab-audio-property))

(defun org-fc-type-vocab-play-slow ()
  "Play vocab audio file at slow speed."
  (interactive)
  (org-fc-audio-play org-fc-type-vocab-audio-property org-fc-type-vocab-slow-speed))

I've bound these to "r" and "R" in my org-fc key bindings. Depending on which card type you're using, similar functions & key bindings could be added for that type.

A general "replay audio" function would be even better, but that would have to track which audio file was the last one played (and correctly reset it after the card was reviewed). org-fc already has a few hooks that are used by org-fc-audio, a new org-fc-after-rating-hook would be ideal for this kind of reset.

At the moment I don't have the time to implement it myself but if you'd like to give it a try, I'd be happy to help.

lcabrini commented 3 years ago

Ok, cool. I just started using org-fc, so I haven't really had a chance to look at creating custom card types yet. In Anki I used them quite a bit.

I'm also quite busy, but I really like org-fc, so I will try to put in a little bit of time and see what I can come up with. I will surely need a bit of help along the way, so thanks in advance.

l3kn commented 3 years ago

I think we can come up with an implementation that doesn't rely on custom card types and instead adds replay functionality to all kinds of cards that use org-fc-audio.

org-fc-audio-play or org-fc-audio-play-file could store the property / file that was most recently played and there could be replay functions that play this property / file again (potentially at a slower speed).

Are you fine with using mpv as a audio player or should we look into supporting different players aswell?

l3kn commented 1 year ago

This feature is now implemented through the ~org-fc-audio-replay~ and ~org-fc-audio-replay-slow~ commands that can be added to the review keymap.