{"id":3764,"date":"2008-11-29T13:19:36","date_gmt":"2008-11-29T13:19:36","guid":{"rendered":"http:\/\/www.paradisec.org.au\/blog\/2008\/11\/how-to-import-a-basic-transcript-into-elan\/"},"modified":"2011-02-05T07:44:25","modified_gmt":"2011-02-05T07:44:25","slug":"how-to-import-a-basic-transcript-into-elan","status":"publish","type":"post","link":"https:\/\/www.paradisec.org.au\/blog\/2008\/11\/how-to-import-a-basic-transcript-into-elan\/","title":{"rendered":"How to import a basic transcript into ELAN"},"content":{"rendered":"<p>The problem: you have text files and audio files, but the text files are not aligned to the audio files.<br \/>\nI imagine there are a few readers out there who have transcriptions of audio files that never made it past an utterance per line text file. This is a post for you, if you&#8217;d like to know how to import and time-align those files in ELAN.<\/p>\n<p><!--more--><br \/>\n<i>[Edit: thanks to <a href=\"http:\/\/anggarrgoon.org\/\">Anggarrgoon<\/a> and <a href=\"http:\/\/www.mactechpeople.com\/\">Honestpuck<\/a> for their suggestions and improvements]<\/i><br \/>\nELAN allows you to import tabbed text, with or without time codes included. The process is described in the <a href=\"http:\/\/www.lat-mpi.eu\/tools\/elan\/manual\/ch04s02s18.html\">manual<\/a>.<br \/>\nTo get it to work you need to convert your text transcript into a &#8220;tabbed text&#8221; file. This means that there will be at least two columns of text, separated by tabs.<br \/>\nFor instance, here is an example transcript:<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_1.jpg\" src=\"\/blog\/images\/transcript_to_elan_1.jpg\" width=\"377\" height=\"384\" \/><br \/>\nI need to remove the blank line between utterances and then I have to add, for instance, the name of the new tier and a tab to the beginning of every line. To do this I&#8217;m going to use the find and replace function in <a href=\"http:\/\/www.barebones.com\/products\/textwrangler\/\">TextWrangler<\/a>, a free (Mac only sorry) text editor that supports <a href=\"http:\/\/en.wikipedia.org\/wiki\/Regular_expressions\">regular expressions<\/a>.<br \/>\nUsing find and replace with regular expressions enabled (check &#8220;Use Grep&#8221; in TextWrangler) to remove the blank line, I replace &#8220;\\r\\r&#8221; with &#8220;\\r&#8221;, and then to add a new column with the name of the ELAN tier in it, I replace &#8220;^&#8221; with &#8220;Monica\\t&#8221;. &#8220;\\r&#8221; is a &#8220;metacharacter&#8221; meaning a return character. For some types of text you may have to use a newline character (&#8220;\\n&#8221;) or a combination (&#8220;\\r\\n&#8221;). &#8220;^&#8221; is a metacharacter meaning the beginning of a line, and &#8220;\\t&#8221; is a metacharacter for a tab. See the link above for more information on regular expressions, and see the references at the bottom of that page for gentler introductions to regular expressions.<br \/>\nThe end result should look like this (where &#8220;Monica&#8221; is the name of the tier that I&#8217;m importing text into):<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_15.jpg\" src=\"\/blog\/images\/transcript_to_elan_15.jpg\" width=\"376\" height=\"384\" \/><br \/>\nNow the text file is ready for importing into ELAN. But before we do that, we need to do a little maths. When there is no time code data, ELAN imports the text with a standard duration for each utterance. If you stick with the defaults, I think you&#8217;ll find that it&#8217;s a pain in the neck aligning the text with the audio. You can vary the duration however. <i>[Edit: IMPORTANT see note <a href=\"#edit\">below<\/a>. Thanks to <a href=\"http:\/\/anggarrgoon.org\/\">Anggarrgoon<\/a> for a much better method!]<\/i><br \/>\nThe problem is that ELAN has no idea where your transcript begins and ends, and so it simply adds the utterances to the beginning of the file. It also gives them a quite short duration by default. Assuming that the length of utterances that you&#8217;ve transcribed do not vary wildly, or that there are long periods of silence, then the best length will be the length of the transcribed portion of your audio divided by the number of utterances.<br \/>\nUse ELAN, or an audio editor like <a href=\"http:\/\/audacity.sourceforge.net\/\">Audacity<\/a> to figure out the length of the transcribed portion of your audio file in milliseconds, and divide it by the number of lines in your transcript. <i> [edit: Don&#8217;t forget to round <b>down<\/b>. Rounding up may result in you loosing some annotations if they fall outside the time span of the recording &#8211; Thanks Tony!].<\/i>If you move the cursor to the last line in TextWrangler, the line number is in the bottom left hand corner.<br \/>\nChoose &#8220;File&#8221; -> &#8220;Import&#8221; -> &#8220;CSV\/Tab delimited text file&#8221;, locate your text file, specify Tier for the column with the tier name, and annotation for the column with the utterances in it. The audio portion for which I have transcribed text is 551930 milliseconds long, and I have 168 utterances in that period.  So I will set the the Default annotation duration to 3285:<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_16.jpg\" src=\"\/blog\/images\/transcript_to_elan_16.jpg\" width=\"400\" height=\"295\" \/><br \/>\nAfter clicking &#8220;OK&#8221; a new ELAN document will pop up. You need to add your audio file by going to &#8220;Edit&#8221; -> &#8220;Linked files&#8230;&#8221;. Add your audio (and\/or video files) and click &#8220;Apply&#8221; and then &#8220;Cancel&#8221; (to close the window).<br \/>\nThen you should shift all the annotations to the beginning of the transcribed portion (just so you don&#8217;t have to scroll backwards and forwards a lot as you properly align the annotations), by going to &#8220;Annotation&#8221; -> &#8220;Shift All Annotations&#8221;. For me, that is 53000 milliseconds into the recording (after I&#8217;ve done my standard introduction).<br \/>\nTo re-align an existing annotation, you need to have the annotation selected by first clicking on it. This will select it and a portion of the audio, and the black underline marking the span of the annotation will change to blue:<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_12.jpg\" src=\"\/blog\/images\/transcript_to_elan_12.jpg\" width=\"489\" height=\"283\" \/><br \/>\nThen you need to select the region of the audio that corresponds to your selected annotation. In my example, they&#8217;re conveniently located very close together:<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_13.jpg\" src=\"\/blog\/images\/transcript_to_elan_13.jpg\" width=\"489\" height=\"283\" \/><br \/>\nYou can play back your selection to check that it&#8217;s right by typing the key combination shift-space, or clicking on the play button with an &#8220;S&#8221; on it. You can extend the selection (if there are two &#8220;chunks&#8221; of audio to one annotation) or reduce it (if you&#8217;ve selected too much) by holding down shift and clicking on the new boundary of the selection.<br \/>\nWhen you&#8217;re happy that the audio and text align, type command-return (on a mac) or control-enter (on a PC) (See also the <a href=\"http:\/\/www.lat-mpi.eu\/tools\/elan\/manual\/ch05s06s06.html\">ELAN Manual<\/a>). You should see the bounds of the annotation (the blue line) shift to your selection:<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"transcript_to_elan_14.jpg\" src=\"\/blog\/images\/transcript_to_elan_14.jpg\" width=\"489\" height=\"283\" \/><br \/>\nSo, lather, rinse, repeat for each annotation and you should have a nicely time-aligned file. Oh, and don&#8217;t forget to save!<\/p>\n<hr\/>\n<p>NOTE: One complication you may run into is that if for instance the annotation you are aligning is quite far from the point in the audio you wish to align it to, then the annotations may move out of order. There is no easy fix to this situation. You may find it easier working from the end of the transcript to the beginning. You may find it easier to first shift those annotations that are closer to their audio counterparts, or you may find it easier to cut and paste annotations into a new tier, so that the process of aligning them doesn&#8217;t shift unaligned annotations elsewhere. Please let me know if you can think of better ways to do this.<br \/>\n<i><br \/>\n<b><a name=\"edit\">Edit:<\/a><\/b><br \/>\nThanks to <a href=\"http:\/\/anggarrgoon.org\/\">Anggarrgoon<\/a> for <a href=\"#c552789\">pointing out<\/a> a <b>much<\/b> simpler method to align annotations with corresponding audio chunks!<br \/>\nFirst of all, ignore my suggestion to extend the duration for imported annotations, a short duration will be ok in this new method.<br \/>\nSecond, turn on &#8220;Bulldozer mode&#8221; under the &#8220;Options Menu&#8221; -> &#8220;Propagate Time Changes&#8221;. This will shift your annotations rather than reorder them. However, you must begin from the beginning.<br \/>\n<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The problem: you have text files and audio files, but the text files are not aligned to the audio files. I imagine there are a few readers out there who have transcriptions of audio files that never made it past an utterance per line text file. This is a post for you, if you&#8217;d like &#8230; <a title=\"How to import a basic transcript into ELAN\" class=\"read-more\" href=\"https:\/\/www.paradisec.org.au\/blog\/2008\/11\/how-to-import-a-basic-transcript-into-elan\/\" aria-label=\"Read more about How to import a basic transcript into ELAN\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,5,6,7,3],"tags":[],"class_list":["post-3764","post","type-post","status-publish","format-standard","hentry","category-fieldwork","category-linguistics","category-paradisec","category-rnld","category-technology"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/posts\/3764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/comments?post=3764"}],"version-history":[{"count":1,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/posts\/3764\/revisions"}],"predecessor-version":[{"id":4104,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/posts\/3764\/revisions\/4104"}],"wp:attachment":[{"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/media?parent=3764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/categories?post=3764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paradisec.org.au\/blog\/wp-json\/wp\/v2\/tags?post=3764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}