]> code.delx.au - gnu-emacs-elpa/blob - packages/transcribe/transcribe.el
* transcribe.el: Fix up formatting and copyright
[gnu-emacs-elpa] / packages / transcribe / transcribe.el
1 ;;; transcribe.el --- package for audio transcriptions
2
3 ;; Copyright 2014-2015 Free Software Foundation, Inc.
4
5 ;; Author: David Gonzalez Gandara <dggandara@member.fsf.org>
6 ;; Version: 0.0.1
7
8 ;; This program is free software: you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12 ;;
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; INSTALLATION
24 ;;-------------------
25 ;; If you don't use transcribe as a package, you can install manually:
26 ;; Copy this file to somewhere in your drive
27
28 ;; To load the file --> M-: (load "~/transcribe.el") --- change the route to where you copied the file
29
30 ;; DEPENDENCIES:
31 ;;-----------------------------
32 ;; In order to use the most important functions of transcribe, you need to install emms and mpg321.
33 ;;
34 ;; DESCRIPTION
35 ;;-------------------------
36 ;; Transcribe is a tool to make audio transcriptions easy. It allows the transcriber to control the audio easily while typing, as well as automate the insertion of xml tags, in case the transcription protocol include them.
37 ;;
38 ;; AUDIO COMMANDS
39 ;;------------------------------
40 ;; C-x C-p --------> Play audio file. You will be prompted for the name of the file. The recommended format is mp2.
41 ;; <f5> -----------> Pause or play audio.
42 ;; C-x <right> ----> seek audio 10 seconds forward.
43 ;; C-x <left> ----->seek audio 10 seconds backward.
44 ;; <f8> -----------> seek interactively: positive seconds go forward and negative seconds go backward
45 ;;
46 ;; XML TAGGING COMMANDS
47 ;;--------------------------------------------------
48 ;; C-x C-n --> Create new episode structure. This is useful in case your xml file structure requires it. You can customize the text inserted manipulating the realted function.
49 ;; <f6> -----> Interactively insert new tag. You will be prompted for the content of the tag. The starting tag and the end tag will be inserted automatically and the cursor placed in the proper place to type.
50 ;;
51 ;;
52 ;;
53 ;; SPECIFIC COMMANDS I USE, THAT YOU MAY FIND USEFUL
54 ;;------------------------------------------------
55 ;; C-x C-a ------> This runs an external discourse analysis tool. It defaults to my own script analyze_episodes2.py, but you can customise the command to launch any other.
56 ;; <f11> --------> Customised tag 1. Edit the function to adapt to your needs.
57 ;; <f12> --------> Customised tag 2. Edit the function to adapt to your needs.
58 ;; <f7> ---------> Break tag. This command "breaks" a tag in two, that is it inserts an ending tag and then a starting tag. Edit the function to suit your needs. It is useful if you are segmenting discourse into tags and then you decide the segmentation was not correct.
59 ;; <f4> ---------> Insert atributes. This function insert custom xml attributes. Edit the function to suit you needs.
60
61 ;;; Code:
62
63 (require 'emms-setup)
64 ;(require 'emms-player-mpd)
65 ;(setq emms-player-mpd-server-name "localhost")
66 ;(setq emms-player-mpd-server-port "6600")
67
68 (emms-standard)
69 (emms-default-players)
70 (require 'emms-player-mpg321-remote)
71 (push 'emms-player-mpg321-remote emms-player-list)
72
73 (require 'emms-mode-line)
74 (emms-mode-line 1)
75 (require 'emms-playing-time)
76 (emms-playing-time 1)
77
78 (global-set-key (kbd "C-x C-p") 'emms-play-file)
79
80 (global-set-key (kbd "<f5>") 'emms-pause)
81
82 (global-set-key (kbd "C-x <down>") 'emms-stop)
83
84 (global-set-key (kbd "C-x <right>") 'emms-seek-forward)
85
86 (global-set-key (kbd "C-x <left>") 'emms-seek-backward)
87
88 (global-set-key (kbd "<f8>") 'emms-seek)
89
90 (defun analyze-episode (episode person)
91 (interactive "sepisode: \nsperson:")
92 (shell-command (concat (expand-file-name "analyze_episodes2.py") " -e " episode " -p " person " -i " buffer-file-name )))
93
94 (global-unset-key (kbd "C-x C-A"))
95 (global-set-key (kbd "C-x C-A") 'analyze-episode)
96
97 (defun draw-boxplot ()
98 (interactive)
99 (shell-command (concat (expand-file-name "/usr/bin/Rscript ") "boxplot_students.R " buffer-file-name)))
100
101 (global-unset-key (kbd "C-x C-B"))
102 (global-set-key (kbd "C-x C-B") 'draw-boxplot)
103
104 (defun define-xml-tag (xmltag)
105 (interactive "stag:")
106 (insert (format "<%s></%s>" xmltag xmltag))
107 (backward-char 3)
108 (backward-char (string-width xmltag)))
109
110 (defun xml-tag-l1 ()
111 (interactive)
112 (insert "<l1></l1>")
113 (backward-char 3)
114 (backward-char 2))
115
116 (defun xml-tag-l2 ()
117 (interactive)
118 (insert "<l2 clauses=\"1\" errors=\"0\"></l2>")
119 (backward-char 3)
120 (backward-char 2))
121
122 (fset 'xml-tag-l2-break "</l2><l2 clauses=\"1\" errors=\"0\">")
123 (fset 'set-attributes "clauses=\"1\" errors=\"0\"")
124
125 (defun display-audio-info ()
126 (interactive)
127 (emms-player-mpg321-remote-proc)
128 (shell-command "/usr/bin/mpg321 -R - &"))
129
130
131 (global-set-key (kbd "<f6>") 'define-xml-tag)
132 (global-set-key (kbd "<f7>") 'xml-tag-l2-break)
133 (global-set-key (kbd "<f4>") 'set-attributes)
134 (global-set-key (kbd "<f11>") 'xml-tag-l1)
135 (global-set-key (kbd "<f12>") 'xml-tag-l2)
136
137 (fset 'NewEpisode
138 "<episode>\n<number>DATE-NUMBER</number>\n<duration></duration>\n<comment></comment>\n<subject>Subject (level)</subject>\n<task>\n\t<role>low or high</role>\n<context>low or high</context>\n<demand>low or high</demand>\r</task>\n<auxiliar>Yes/no</auxiliar>\n<transcription>\n</transcription>\n</episode>")
139
140 (global-unset-key (kbd "C-x C-n"))
141 (global-set-key (kbd "C-x C-n") 'NewEpisode)
142
143 ;;; transcribe.el ends here