воскресенье, 30 октября 2016 г.

Spreadsheet tool to convert between .srt and .txt

Movie subtitles (*.SRT)

Audacity does not yet directly support movie subtitle files (*.srt). This page explains the use case for *.srt support in Audacity and offers tools to convert an .srt file to and from a .txt file which can display the subtitles as Audacity labels.

Contents

 [hide

Use Case

You can already use Audacity's labels feature to read or write subtitles (such as translations, transcriptions or comments) for a movie audio track. Use the current Audacity and add the optional FFmpeg library to your computer. This will allow you to import the audio from a video file such as AVI or MPEG, or from a VOB file from an unencrypted DVD. Then convert your .srt file to .txt using the converter below and choose File > Import > Labels to import the .txt file.
You can also use movie subtitles in Audacity to record your own dubbing of the subtitles and then mix your voice into the movie audio track.
Unfortunately the layout of timings and text in .srt subtitle files is slightly different to that used in the .txt files for Audacity labels. It would be easier if you could directly import and export .srt files instead of having to convert them to .txt to import them into Audacity, then convert them back to .srt for use in a video player. Other features suggested in Proposal Transcription Editor would also improve the experience of working with subtitles in Audacity, such as:
  • A movie window synchronised with the audio track
  • A way of nudging labels along with a shortcut in order to position them accurately
  • Text-to-Speech (TTS) support in Audacity would allow a synthesized voice to read or record the subtitles automatically.

Label2Srt: Label to SubRip / subtitles (.srt) converter

Label2Srt is a small open source Java application to convert label files into SubRip (.srt) files, written by AndrewTheArt. This is similar to Label2Cue released about 6 years ago.
See relevant forum post here.
SRT files are subtitle files that can be read by many video players (including Youtube)

Step 1: Create the label files in Audacity

In order to do the conversion, first create labels in your audio file in Audacity one of two ways:
  • (Method 1) Drop a label at specific location with CTRL+B and stretch it to create a "time span" for the subtitle. Name the label if you wish. This is the preferred method.
  • (Method 2) Drop a label at with CTRL+B. Drop a second label at another position. Name the labels if you wish. Label2Srt treats the first label as the start of the subtitle and the second label as the end of the subtitle. Repeat as many times as you want.
Label2Srt deals with both cases. In Method 2, a time span is created in the SRT from Label 1 to Label 2, then from Label 3 to Label 4, then from Label 4 to Label 5, and so on.

Step 2: Export the labels

In Audacity, select File > Export Labels and name your exported label file. It will be saved as a plain text document that represents the label positions in seconds (and optionally, the label titles).

Step 3: Execute the Label2Srt program

In both operating systems (Windows and Linux) you can simply double click on the jar file.
In Windows, you might also try right clicking on the file and selecting "Open With -> Java(TM) Platform SE Binary".
Optionally, execute,
java -jar Label2Srt.jar
via the Windows / Linux command line.

Step 4: Use the Label2Srt program

Select the label text file with "Select" button which opens a file browser. Then, press "Convert". The new SRT file is saved to the same directory as the label file.

Contact with Bug Reports

andrew1stein - AT - gmail - DOT - com

Spreadsheet tool to convert between .srt and .txt

Supported formats: Audacity Labels (TXT), Movie SubRip Subtitles (SRT), YouTube Captions (SBV)
It is an .xls (Microsoft Excel) file with a single sheet and two macros. To open it you have to install a spreadsheet application such as Microsoft Excel or OpenOffice.org.

Opening the Convertor

After opening the .xls file you may have to give authorisation for the macros to run. To do this you can just enable macros at the security prompt (menu bar or popup window) or better could be to mark the signed publisher (mederi) as a trusted source. Marking as "trusted" will remove any further prompts when you re-open the file. You can also either reduce the default security level for all documents (not recommended) in the spreadsheet tool's options, or add the location (folder) you are opening the file from in a list of trusted locations.

Converting Subtitles.srt to Labels.txt and vice versa

Follow the simple instructions in the file. There is an example of .srt format subtitles in the first column on the left.
To convert the movie subtitle file (*.srt) content to Audacity label file (*.txt) format:
  1. Press the SRT to TXT >> button - the converted content will appear in the three columns on the right
  2. CTRL + C to copy
  3. Open a text editor that supports Unicode or UTF-8 like Notepad++
  4. CTRL + V to paste the content in
  5. Save the file in UTF-8 or Unicode encoding with .txt extension.
If you use Microsoft Notepad (included with Windows) to save the file, be sure to use File > Save As and choose UTF-8 or a Unicode encoding. If you just File > Save, the file will be encoded in ANSI. This will result in Audacity not being able to open the saved file properly if it contains other than English characters.

Converting from .txt to .srt after exporting the labels.txt file from Audacity is similar:
  1. Open labels.txt in the text editor
  2. CTRL + A followed by CTRL + C
  3. Open the .xls file
  4. Click in column G of row 4 and CTRL + V to paste into the three columns on the right
  5. Press TXT to << SRT to place the result in the single column on the left
  6. Now you can copy this content, paste it into your text editor and save it with .srt extension (ANSI encoding should be fine).

Creating Audio Flashcards with Transcriber, Audacity, and Anki

screenshot-installing files to Transcriber export directory

TranscriberAudacity, and Anki are three programs, all free and open source, that are useful for language study. At some point in the future, I hope to write more on each of these. In the meantime, I wanted to announce two export plugins I created for Transcriber. One export creates a label file for Audacity, for splitting an audio file into individual clips, and the other creates an import file for Anki, associating the transcribed text with the audio segments. Below are step-by-step instructions for the 6 steps involved, starting from a raw audio file and finishing with a set of Anki flashcards.

Step 1

Download the plugin files anki_audio_cards.tcl and audacity_labels.tcl from the zip file or individually, and put them into the lib/transcriber1.5/convert/ subdirectory of the Transcriber program location. If Transcriber is running, you will need to restart it for the plugins to take effect.
screenshot-installing files to Transcriber export directory

Step 2

Create an episode project in Transcriber. Split up the audio into turns of 1 sentence or less. Individual turns shouldn’t be too long, as the resulting clips would be sub-optimal for SRS use. The project should have at least one section (e.g., a report section) with a title describing the topic. The topic(s) are carried through to the Anki import, so they can be used as an optional title along with the audio prompt. One of the export fields is the sentence number within each section. If multiple sections are used, the numbering will restart at 1 for each new section.
screenshot-Transcriber project file
If the episode attribute “Program” is set, this is inserted as a comment at the top of the Anki import file. Multiple lines in this comment can be delimited with the string “<eol>”. While this information doesn’t get imported into Anki, it can be useful for reference purposes if the import file is kept.
screenshot-editing Transcriber project attributes

Step 3

Export the Transcriber project to two files, using both the plugins:
a) File->Export->Export to Anki Audio Cards..
b) File->Export->Export to Audacity Labels…
screenshot-Transcriber export submenu

Step 4

Open the original file in Audacity (Transcriber does not need to be closed). Then, select Project->Import Labels and choose your previously exported labels file (the default file extension is “-labels.txt”). The result should be a new label track with named flags. These flags should be in the same locations as the original Transcriber segments; i.e., the times shouldn’t be cutting the middle of a sentence anywhere. Due to a bug in the time calculation of Transcriber, the splits may gradually drift from the original locations, eventually moving into the non-silent audio itself and cutting it off. The Transcriber export plugins account for that and compensate for it; however, I don’t know at this point if the adjustment factor of 0.995472 is machine-dependent. If you’re adventurous, you can edit the plugin files and change the adjustment factor yourself to correct the problem.
screenshot-Audacity with imported label track
[If you wish, this is a good point to adjust the audio volume, if it's too low. Select the entire waveform, and choose Effect->Amplify. The maximum amount of increase before clipping occurs is pre-calculated. If it's still too low, check "Allow clipping" to enable a higher range, at the expense of occasional distortion.]
Select File->Export Multiple from the menu. Choose your export format for what you want to use within Anki (e.g., mp3). The Export location can be anywhere, but note that eventually this directory will need to be a subdirectory of your Anki deck, and named <your deck>.media. Split files based on labels, and name files using label/track name.
screenshot-Audacity export multiple
The result should be a series of small audio files, named with the original Transcriber episode name, appended by a millisecond timestamp.

Step 5

Using a text editor, look at the Anki data file (defaulted to a .tab file extension) exported from Transcriber. There should be four columns in the data section, separated by tabs:
  • file basename
  • segment text
  • section title
  • line number within section
Delete any rows you don’t want to make cards for, such as silent segments or music interludes. You should also delete the corresponding audio clips, since they won’t be used.
If you need to do more complicated editing to the data file, a spreadsheet program works great.
screenshot-Excel editing Anki audio card data

Step 6

There are a lot of ways to configure a deck in Anki, so I will just present the basics. If you are using this data as starter material for a new deck, first create a blank deck. Next, edit the model, the card layout of the forward template, and add four fields. Instead of the default Front and Back, create fields for Basename, Reading, Topic, and Sequence (or other names of your choosing).
screenshot-Anki field names
For the card template itself, the following is an example:
Question:
[sound:{{text:Basename}}.mp3]
Topic:{{Topic}}
({{Sequence}})
Answer:
({{Sequence}}) {{Reading}}
screenshot-Anki audio card template
Choose File->Import to start importing the .tab data file. The import dialog should auto-detect a tab delimiter. If you set up your four fields as above, the field mapping will automatically be set to the correct import order: 1=Basename, 2=Reading, 3=Topic, and 4=Sequence. If the order is wrong, change the mapping as needed. After the mapping is set, click the Import button to load the data. As part of the import, each card will include tags for “audio” and for the original episode name.
screenshot-Anki import records
Tags: 

Переместить файлы по маске в папки, соответствующие маскам


В источнике выделяется энное количество папок, в которых есть файлы. 
В получателе открывается другая папка. 
Как из выбранных в источнике папок скопировать/переместить только содержащиеся в них файлы, а не сами папки? (тип файлов не имеет значения). 
Знаю, можно использовать поиск в выбранных папках. Потом вывести найденный файлы на панель и нажать F6. Это долго! 

Ответ ещё проще. Открыть в исходной панели корневую папку, включающую всё необходимое, перейти в режим показа файлов без подкаталогов (Ctrl+B) - и копировать. Но если в разных исходных подкаталогах есть одноимённые файлы, хорошенький конфликт имён при копировании гарантирован. Внимательно следить за запросами на перезапись!






TOTAL COMMANDER 9





Код:
'=================== VBS ===================
Переместить файлы из каталога под курсором
' в папки с именами соответствующих им масок
' Параметр: %V
'===========================================
Option Explicit: Dim Filt, Fold, FSO, ShAp, Items, Mask, Name, Path
'===================== Маски файлов через "|" =====================
Filt = "1*.*|*name*|name*.txt|name 1.txt|name 1*.txt|name *1.*|" &_
"*2*|2.txt|name2.txt|name 2.txt|name *2.txt|name 2*.*|name 2.*|" &_
"*3*.txt|name 3.*|name3.txt|name 4.txt|name *4*.txt|*5*|*5*.txt"
'==================================================================
Fold = WScript.Arguments(0)
Set FSO  = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(Fold) Then WScript.Quit
Set ShAp = CreateObject("Shell.Application")
Set Fold = ShAp.NameSpace(Fold)
Set Items = Fold.Items
For Each Mask in Split(Filt, "|")
  Items.Filter 73920, Mask
  If Items.Count Then
    Name = Replace(Mask, "*", ChrW(-246))
    Path = Fold.Self.Path & "\" & Name
    If Not FSO.FolderExists(Path) Then Fold.NewFolder(Name)
    ShAp.NameSpace(Path).MoveHere Items
  End If
Next

пятница, 14 октября 2016 г.

Как добавить Google Forms на страницу в Facebook

 

Рассмотрим пример, как очень быстро вставить форму, созданную в Google Forms, на Facebook-страницу. 
В каких случаях можно использовать формы Google на странице в Facebook?
  • Проведение опросов
  • Обратная связь и предложения
  • Продажа продукта на странице
  • Регистрация на мероприятия (например, вебинары)
  • Участие в конкурсе (с помощью форм можно создать что-то вроде викторины для подписчиков страницы)

Часть 1: Создание формы Google

1. Для начала, вы должны создать форму Google. Зайдите в своей аккаунт Google Drive, а затем нажмите кнопку Создать и выберите Google Формы.
1
2. Откроется новая вкладка, с просьбой ввести название формы.
3. Теперь необходимо создать перечень полей ввода, которые пользователи будут заполнять при открытии формы.
4. После того, как все поля подготовлены, можно сменить тему (по желанию) и нажать кнопку Отправить.
3
После нажатия на кнопку Отправить, вам будет предложен HTML-код, для интеграции формы на страницу сайта или вкладку Facebook-страницы.
4
Скопируйте предложенный код. Он нам понадобится дальше.

Часть 2: Создание дополнительный вкладки на странице в Facebook

Facebook не позволяет пользователю напрямую добавить HTML или IFRAME на страницу. Существует два способа обойти это ограничение.
Первый (самый правильный, но наиболее трудоемкий) заключается в создании собственного приложения.
Второй способ, с использованием стороннего приложения, достаточно прост и под силу каждому. Остановимся именно на нем.
1. Откройте приложение Static HTML: iframe tabs и нажмите на кнопку Add Static HTML to a Page. Выберите страницу, на которую хотите добавить новую вкладку.
5
В списке будут только страницы, к которым у вас есть права администратора.
2. Результатом будет новая вкладка на выбранной странице. По-умолчанию, вкладка называется Welcome (можно переименовать). Перейдите на страницу и откройте эту вкладку.
6
На вкладке будет кнопка Edit Tab. Нажмите ее и откроется редактор.
3. Вот сюда вам и нужно вставить HTML-код формы Google, полученный в первой части статьи. У меня получилось примерно следующее:
7
Как видите, я изменил параметры width (ширина) и height (высота) для более красивого отображения формы. Ширину можете оставить 810 (именно такая ширина у любой вкладки в Facebook), а вот высоту подбирайте под свою конфигурацию формы. Главное — чтобы не было никаких скроллов и форма отображалась на вкладке во всю высоту.
4. Сохраняем и получаем на Facebook-странице вкладку с формой Google.
Google Drive умеет хранить результаты заполнения формы в отдельном табличном файле. Чтобы активировать эту возможность, откройте свою форму в Google Forms, далее пункт меню Ответы -> Сохранять ответы и убедитесь, что установлены следующие настройки:
8
Если вы используете Google Формы на своих Facebook-страницах, присылайте ссылки в комментариях к этой статье.