Copy Clean Lyrics to Clipboard script

I looked out there for something like this like but couldn’t find it, so I ginned up a script to copy the lyrics in a track to the clipboard, but remove the “br” and “hh” and such. The idea is you can paste it to a text file and save your “as built” lyrics. Might be handy for websites that like to have lyrics entered when you upload.

It attempts to do a little formatting as well (tho some clean up will still be necessary). Please see the readme area in the script for details.

(To install, you can hit the “Download Raw File” button on the upper right of the github page and save the file into your SynthV “scripts” folder, then hit Scripts->Rescan in the SynthV UI.)

「いいね!」 2

Hi @Finney
Nice bit of coding :+1:
I’m trying to amend your code (with limited success) to get the same extract but for the phonemes that are assigned to the lyrics, to include default text and/or user entered phonemes.
I’ve managed to get an extract of just the user entered phonemes but it ignores the default pronunciations (UK/English locale).
I imagine its use will be where other SV users are struggling with the pronunciation of certain words i.e. Anglicising some of the pronunciations that tend to be a bit USA heavy.
We can then share how we achieved certain words to help others or even start a general pronunciation reference dictionary?? (possibly over ambitious but hey ho, its beer o’clock :grin:)

I tagged this into your code to test and i get the phoneme text from the clipboard but it has gaps. Can you suggest where I might be going wrong (I’m not a coder by trade if that’s not obvious :wink:):

        curr = lyric_current:getLyrics()
		currP = lyric_current:getPhonemes()
		if (table.contains(ignoreList,currP) == false) and string.sub(currP, 1, 1) ~= '.' then
			if string.len(phonemes) > 0 and IsUpper(string.sub(currP, 1, 1)) then phonemes = phonemes.. '\n' end
		
			phonemes = phonemes .. lyric_current:getPhonemes() .. ' '
		end
	end
	SV:setHostClipboard(phonemes)

Hi @GBTbass

OK, I see what you’re trying to do. It looks like, from the SynthV API, that we need to use a different method – ‘getPhonemesForGroup’ – to get the regular phonemes.

It’s kind of an all or nothing thing though, we can’t do only selected notes from what I can see, without doing some weird sort of matching coding. Also, line breaks are more problematic here.

Here’s the relevant code that would get it started:

function table.contains(table, element)
  for _, value in pairs(table) do
    if value == element then return true end
  end
  return false
end


function copyPhonemesToClipboard() 
	local phonemes = SV:getPhonemesForGroup(SV:getMainEditor():getCurrentGroup())
	phonemes_str = ''
	local ignoreList = {'br', '-', 'hh', '+', 'sil', 'cl'}
	for _, lyric_current in pairs(phonemes) do
		if (table.contains(ignoreList,lyric_current) == false) and string.sub(lyric_current, 1, 1) ~= '.' then
			phonemes_str = phonemes_str .. lyric_current .. '  '
		end
	end	
	phonemes_str = phonemes_str:gsub('    ', '\n')
	SV:setHostClipboard(phonemes_str)	  
end


function main() 
  copyPhonemesToClipboard()
  SV:finish()
end
「いいね!」 1

The indices of the array returned by getPhonemesForGroup will align with those of the respective notes in the group.

So for example, SV:getPhonemesForGroup(currentGroupRef)[5] will return the phonemes for the note you’d find by currentGroupRef:getNote(5). Or to do the inverse, you could use note:getIndexInParent() and then check that index in the phoneme array.

You can find a simple (JS) implementation of a similar – but also much simpler – script here: https://github.com/claire-west/svstudio-scripts/blob/3d0860ef83481caa959a4c0e4564c39724735d2d/hotkey-scripts/CopyPhonemes.js

Hope that helps.

Hey Claire,

That does help! And…I just realized I did not reference your script from my first one above. :frowning_face: When I’ve ‘borrowed’ your stuff before I’ve mentioned it in the comments.

I should have looked back to what you were doing before trying to reinvent the wheel. I guess the ‘weird matching coding’ is pretty simple in the end, as you show!

for (var i = 0; i < selectedNotes.length; i++) {
    var noteIndex = selectedNotes[i].getIndexInParent();
    phonemes.push(groupPhonemes[noteIndex]);

My original aim was just to get some clean lyrics out. (In the past I’ve actually exported the tracks as UST files and then gone in and manipulated those to get the lyrics.)

Thanks!

「いいね!」 1

Thanks @Finney @claire , i’ll have a play and see what comes out. Appreciate the effort on this :+1:
GBT