Keyboard Input Converted Word Playback Based on Syllables
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hello,

I have a site spitsomebars.com

There are user submitted rap lyrics on the site

I want users to be able to tap out rhythms, and then see the words in the rap bars appear syllable by syllable according to the tapped rhythm.

The system should allow a user to:

  1. Click a "record" button next to his/her own bars (rap lyrics)
  2. Tap out rhythm using the "B" and "M" keys on the keyboard (or a button for the mobile site). Each tap on the keyboard/button is associated to the next syllable. For example, for the line "I went to my car. Nobody knows my scars" would be tapped out as: tap tap tap tap tap (I went to my car) taptaptap tap tap tap (Nobody knows my scars)
  3. Remember that rhythm (tapping sequence) in the database
  4. Display a "Play" button along with each rap lyric that any user can click and see the words in the rap appear syllable by syllable according to the tapping sequence
hi there, i made an account for test already, i'm asking for more explanation, can i have that? for now, i'm understanding it for this example "I went to my car. Nobody knows my scars" as you described : tap tap tap tap tap (I WENT to my car) taptaptap tap tap tap (Nobody knows my scars) associated as tap (I) tap (WENT) tap (to) tap (my) tap (car) tap (No) tap (bo) tap (dy) tap (knows) tap (my) tap (scars). if i'm getting it right, please tell, i can do it. i'm thinking of it, and i think i have a solution for it :p
Chlegou 3 months ago
Yes! That is the correct association: (I) tap (WENT) tap (to) tap (my) tap (car) tap (No) tap (bo) tap (dy) tap (knows) tap (my) tap (scars)
dev 3 months ago
great! :D now i have several question, please answer them carefully, so you help me figure it out correct. 1/you are looking for animating the display of the rap bar sequence by sequence right? should tap will be represented by something or just empty (blank)?
Chlegou 3 months ago
Yes, I'm looking to animate the rap bar sequence by sequence. The "tap" won't show anywhere. It's just representing the keyboard tap... Not sure if I've understood this question
dev 3 months ago
yes correct :) i will start working on that :) i will see what i will reach ;)
Chlegou 3 months ago
You need frontend solution right?
Codeword 3 months ago
Yes front end solution. I am using mongodb/expressjs, so the "tap sequence" will have to be stored in the database. However, as long as your solution can output an array that I can spit into my db (and then read the tap sequence from that array), we should be good. I'm very excited for your solution!
dev 3 months ago
I might have a hunch, do you need a simple algorithm? so that you could do it for your own db without having to go through parseing and stuff? (I am assuming you code)
SilverHood Apps 3 months ago
do you want the solution is php or js?
Chlegou 3 months ago
@ Houcem Solution in js please @SilverHood Apps a simple algorithm is fine. My coding skills are alright - if you can give me 1) js code to generate an array out of the user's recorded taps sequence 2) js code to read an array of taps and spit out syllables in a bar according to the sequence. I know how to put that array into my db and then also get that array from my db and give it to your code. Hope that helps
dev 3 months ago
Ok great, and your expected output is - "I went to my car. Nobody knows my scars" when played to be a) "I went to my car. Nobody Nobody Nobody knows my scars" b) "I went to my car. car. car. Nobody knows my scars" c) kindly let me know what taptaptap would be..
SilverHood Apps 3 months ago
@SilverHood, no - that is incorrect. taptaptap means Nobody would be displayed as No bo dy. See Houcem's original comment: (I) tap (WENT) tap (to) tap (my) tap (car) tap (No) tap (bo) tap (dy) tap (knows) tap (my) tap (scars)
dev 3 months ago
why you have set different keys m and b. Is b used to enter space between taptap like this tap tap ?
Codeword 3 months ago
Ok got it..
SilverHood Apps 3 months ago
@dev i have updated my bounty, please have a look on it :) in principle, i think what you want is perfect, (didn't followed the key suff, because, if he did make a mistake, it will be impossible to fix, and he have to re do it again) , anyway, please let me know your opinion about my work :)
Chlegou 3 months ago
Does my solution work for your use case? @dev
SilverHood Apps 3 months ago
Hello Dav, I have updated my code and errors have been remove and also have added the timestamp functionality associated with each tap as you wanted.Thank you.With warm regards #Codeword
Codeword 3 months ago
Thanks @dev!
SilverHood Apps 3 months ago
by the way, i tested @codeword example, i noticed, that user cannot edit recorded sequence, and that's why, i didn't followed that logic from the beginning. think about it please. it's something important ;) we can interact somehow mixing both solutions to have stable thing ;) (an idea if you want, add "r" action, that will add remove action, in the code, with auto view helper) have a nice working set! ;)
Chlegou 3 months ago
@Houcem B.A. chlegou , editing a recorded sequence is a trivial task and a whole new thing, I have not added it because it not needed here,As the bounty poster clealy stated that " My coding skills are alright - if you can give me 1) js code to generate an array out of the user's recorded taps sequence 2) js code to read an array of taps and spit out syllables in a bar according to the sequence. I know how to put that array into my db and then also get that array from my db and give it to your code" Thank you.
Codeword 3 months ago
@codeword i know that @dev didn't required that, but still something important and helpful to have backward when recording ;) and it would be perfect, to do that :) keep up the good work! :) again together we are working on the same bounty :p really was nice to work together ;)
Chlegou 3 months ago
Nice to work with you too @ Houcem B. A. Chlegou .Keep it up :)
Codeword 3 months ago
@Houcem B.A chlegou , One more thing to notice is that, The user won't be able to edit (but of course can always re enter if needed)the tap sequence in anyway(not only in my solution but this will be true for all solution) no matter what, as user will not be able to see the tap sequence unless it is shown to the user explicitly in textual form which in that case the user can edit easily then.Apart from this everything is working as intended.Thank you.
Codeword 3 months ago
awarded to Codeword

Crowdsource coding tasks.

3 Solutions


This does not require you to rememeber the sequenct at all,

it gives spaces to every 1st word of 2nd lines in verse / bar you may call it..
here's a working solution

Displays

Tomas the Tank

Drinks like a skank

Bought a boat on Tuesday,

Then he watched it sank

as

Tomas the Tank

Dr in ks like a skank

Bought a boat on Tuesday,

Th en he watched it sank

<!DOCTYPE html>  
<html>  
<body>  
<p>Click the button to display the array values after the split.</p>  
<button onclick="myFunction()">Try it</button>  
<p id="demo"></p>  
<script>  
function myFunction() {  
// get the text from your db into str  
var str = document.getElementById("xyz").value;  
 var lines = str.split('\n'); //split text by each line  
    var newlines="";  
    var bar="";  
    var special_word="";  
for(i=0;i<lines.length;i++){  
  var index = i+1;            // just to make 0 to 1 and so on  
  if(index!=0 && index%2==0){ // choose every 2nd line  
    //split the last word 2 times  
    var words_arr = lines[i].split(" ");  
    //for(k=0;k<2;k++){  
    // get the 1st word of 2nd line  
     special_word = words_arr[0];   
     // add space between each 2 alphabets  
     var word = special_word.split("");//Nobody  
     special_word = "";  
       for(l=0;l<word.length;l++){  
           var index2 = l+1; //to make it start from 1  
           if(index2%2==0){  
               special_word+=word[l]+" ";//No   
           }else{  
               special_word+=word[l]; // No b  
           }  
       }   
     //replace Nobody with No bo dy   
    words_arr[0] = special_word;  
    //join the words to form single line  
    lines[i] = words_arr.join(" ");  
   }  
  bar += lines[i]+" <br>";  
  special_word = "";  
}  
//display or animate  
document.getElementById("demo").innerHTML = bar;  
}  
</script>  
<textarea id="xyz"></textarea>  
</body>  
</html>  

Just copy past above code to html & run

Best i could do all night.. I hope it helps in some part of you requirement if not all,

Tip would be still appreciated :)

ps: I am off to sleep its 5:20 am in India right now, got exam at 10am. :P i hope it helps. Gn
SilverHood Apps 3 months ago

Here i'm, was following that @codeword worked on building the sequence, so started directly working on playing the rap bar. and it's working :D. (still quick fix to separate sequences but i will do it by the end :p )

Update: play function is fixed as wanted!! taptap is working :p

here is the working demo from my server:

link: http://orbitcoins.website/demos/demo%20-%20lazyspell/lazyspell.html

Next Work: i will start working on saving the sequence (demo is working with static sequence)

my sequence structure is following this easy logic, if any one want to interact and help.

var text = "I went to my cars. Nobody knows my scars.";
var spellParts = [[1],[4],[2],[2],[5],[2,2,2],[5],[2],[6]];

Update
i finished by making a file, that contain, the two functions, play and record. play will play a text from serialized array that should be saved in your database, and record, that will record it in the right format. the basic principle, is really simple, it split the string by spaces, then every word will be made apart, to facilitate it.

imporovements
add masked validation fro the inputs, so no wrong serialized arrays are saved, or even better, add front end control for them (need extremely hard work, to make it clean).

links: my server link is updated with latest files. also, i added a JsFiddle demo.

link1: http://orbitcoins.website/demos/demo%20-%20lazyspell/lazyspell.html

link2: https://jsfiddle.net/r662yvsf/

by the end, hope you like my work :)

Thanks for the tip! :)
Chlegou 3 months ago
by the way, i tested @codeword example, i noticed, that user cannot edit recorded sequence, and that's why, i didn't followed that logic from the beginning. think about it please. it's something important ;) we can interact somehow mixing both solutions to have stable thing ;) (an idea if you want, add "r" action, that will add remove action, in the code, with auto view helper) have a nice working set! ;)
Chlegou 3 months ago

Final 100% working code
all errors have been removed and
added timestamp funtionality

$(document).ready(function(){
  var record=false;
  var tap_sequence='';
  var last_key_pressed='none';
  // note sleep function no longer needed
     /* 100% working (tested)main part of code generating tap sequence*/

     **Main code for generating tap sequence**

     $(document).keypress(function(event){
         var key= String.fromCharCode(event.which).toLowerCase();
           /* pressing m will produce taptaptaptap  */
           if(key == 'm'){
             if(last_key_pressed=='m'){
              tap_sequence+='tap.';   /* for sequence like taptaptap*/
             }else if(last_key_pressed=='b'){
              tap_sequence+= 'tap.';   /* for sequence like taptaptap*/
             }else{
               // no code needed here just for formailty
             }

           }else if(key == 'b'){   /* pressing b will produce tap tab tab  */
              var last_char=tap_sequence.slice(-1);  /* last char*/
              if(last_char=='.'){     /*if last char is . then remove it*/
                tap_sequence=tap_sequence.slice(0,-1);
                tap_sequence+='#';    /* append a blank space*/
              }
              tap_sequence+='tap#';   /* for sequence like tap tap tap*/

           }else if(key =='none') {
              tap_sequence='tap#';
           }else{
             /*No code needed here just for formailty*/
           }
           last_key_pressed=key;

     });
     /* set record to true when record button is pressed*/
     $('#record_button').on('click',function(){
        record=true;
        tap_sequence='';

     });
     /* clear tap sequence and also set record to false when clear tap button is pressed*/
     $('#clear_tapsequence_button').on('click',function(){
       if(confirm('Are you sure you want to clear the tap sequence')){
         record=false;
         tap_sequence='';
       }
     });
     /* send tap sequence to database using ajax*/
     $('#save_sequence').on('click',function(){
        var sequence=tap_sequence.slice(0, -1);  /*removing extra . or # at the end*/
        if(sequence!='' && record==true){
          if(confirm('Are you sure you want to save the tap sequence')){
            $.post('store_tap_sequence.php',{sequence:sequence},function(data){
               if(data=='Ok') {
                 alert('Sequence successfully captured');
                 tap_sequence='';
               }
               else alert('Sequence couldn\'t be captured' );

            }).error(function(){
               alert('Error, Ajax Load File Missing');
            });
           }
        }else{
           alert('Tap sequence empty');
        }
     });

      /*play button for each track*/

    **Main code for playing**

     $('.play').on('click',function(){
        var ref=$(this);/* refernec of which play button was pressed*/
        var rap_text=ref.data('rap_text'); /* the rap text imported from database eg: I went to my car. Nobody knows my scars */
        var sequence_text=ref.data('tap_sequence_text'); /* tab sequence in textual form imported from database eg.  tab#tab#tab#tab */
        var rap_text_array=rap_text.split(" ");
        var sequence_text_array=sequence_text.split('#');
        var text_progress='';
        var interval=0;
        var timestamp_array=[];
         $.each(sequence_text_array, function (index, value) {
              var temp_arr=value.split('.');
              var temp_arr_len= temp_arr.length;
              if(temp_arr_len >1){
                  var x = parseInt(rap_text_array[index].length/temp_arr.length);
                  if(x!=0){
                    for(var j=0;j<temp_arr.length;j++){
                      var tempo_var= temp_arr[j].split('@'); /* for spliting tap@14522563535 */
                      timestamp_array.push(tempo_var[1]);
                      ref.parent().prev().children('p')..append('<span class="syllable" style="display:none;">'+rap_text_array[index].slice(j*x, (j*x)+x)+' '+'</span>');
                    }
                  }
              }else{
                var tempo_var=value.split('@');/* for spliting tap@14522563535 */
                timestamp_array.push(tempo_var[1]);
                text_progress+=tempo_var[0]+' ';
                ref.parent().prev().children('p').append('<span class="syllable" style="display:none;">'+rap_text_array[index]+' '+'</span>');
                /*  playbutton--> parent of playbutton(ratingwidget) --> previous element (blockquote) ---> paragraph of blockquote(p) */
              }
            });

            $.each($(ref+'> .syllable'), function (index, value) {
                $(this).delay(interval).fadeIn("slow");
                if(index ==0)
                interval += 100;
                else
                interval += parseInt(timestamp_array[index]-timestamp_array[index-1]);

            });

       });
});

usage example :

rap text= " **I went to my cars. Nobody knows my scars.**"
tapsequence = **bbbbbmmmbb**    equivalent to(**tap tap tap tap tap taptaptap tap tap**)

output = **I went to my cars. No bo dy knows my scars.**  along with timestamp effect
This is very close! One thing: if I feed your code a string (a random example from the website: "Champ champ champION doin that shit what can't be DONE strong like an ox, brave like a lion going on and on and on and on and ON!" How will your code know how to break up that string into syllables?
dev 3 months ago
I know there is some error, I am just about to post the latest code wait a min
Codeword 3 months ago
Also, there should be some timestamp associated with each tap. If I tap for "No" in "Nobody", and then 5 seconds later I tap again for "bo" in "Nobody", the playback should show "No" and then 5 seconds later show "bo" ---- hope that makes sense...
dev 3 months ago
okay This can be done.
Codeword 3 months ago
Also check you code with this ``` var raptext="I went to my car. Nobody knows my scars"; /* the rap text imported from database eg: I went to my car. Nobody knows my scars */ var sequencetext="tap#tap#tap#tap#tap#tap.tap.tap#tap#tap#tap#tap"; /* tab sequence in textual form imported from database eg. tab#tab#tab#tab */ ``` It's woking, just add some delay for smooth operation as you wish.
Codeword 3 months ago
Meanwhile I am adding the timestamp functionality.
Codeword 3 months ago
Hello dev I have fixed the previous error and also added the timestamp functionality as well. How it works here b 's are used for tap tap tap like sequence and m 's are used for taptaptap like sequence for example if rap text = " I went to my car. Nobody knows my scars " AND if tap sequence is bbbbbmmmbb then output string generated is tap@1542426#tap@1542426#tap@1542426#tap@534214#tap@3313.tap@3223.tap@654654#tap@67555#tap@67555 Which is then used by play functionality .
Codeword 3 months ago
Hi codeword! First, just wanted to let you know that you've already secured the bounty. I'll also tip. I have yet to try this code - I'll get time this weekend hopefully, otherwise early next week. One thing: I'm understanding that, in your code, "b" is for whole words and "m" is for breaking up a word. However, when I'm tapping out the beat for the bars, I'm not paying attention to which key I'm hitting. If I hit "b" or "m", it shouldn't matter - only the timing between taps matters. The code should be able to break up a bar syllable by syllable, and then each tap has a timestamp associated.
dev 3 months ago
Hi codeword! First, just wanted to let you know that you've already secured the bounty. I'll also tip. I have yet to try this code - I'll get time this weekend hopefully, otherwise early next week. One thing: I'm understanding that, in your code, "b" is for whole words and "m" is for breaking up a word. However, when I'm tapping out the beat for the bars, I'm not paying attention to which key I'm hitting. If I hit "b" or "m", it shouldn't matter - only the timing between taps matters. The code should be able to break up a bar syllable by syllable, and then each tap has a timestamp associated. See my solution for pseudo code on what I'm trying to accomplish.
dev 3 months ago
This is exactly what my code is doing, using tap@1542426 where 1542426 is the timestamp associated.
Codeword 3 months ago
Oh, so I can tap out the whole sequence with just the "m" key if I wanted?
dev 3 months ago
One more thing if we don't use different keys (in this case b and m ) then there will be no way of knowing whether the user wants to generate tap or taptap.Even after all this if we want that the sequence shouldn't depend on b or m rather any key, then we'll have to depend on timestamps to know if the user pressed tap or tap tap by considering a time threshold like for example say 300ms.If the user presses bb(or any two consecutive key press) and the time interval between the two b(or any key) is less than 300ms then bb(or any two consecutive key press) would be considered as taptap otherwise tap tap(if the interval is greater than the threshold).Let me know how would you like to proceed.Thank you
Codeword 3 months ago
I would recommend you to use different keys, as the 2nd method would be prone to error.But the second method can be also implement with a little modification in $(document).keypress(function(event){}); not more than one or 3 lines.Thank you
Codeword 3 months ago
I see what you're saying, but from a user's perspective, it will be hard to tap m for syllables and b for words. Is it possible to use b or m for any tap and make the threshold 10ms? The rate at which syllables appear in the play function should be completely dependent on the timestamp. Let me know if there's a way I can talk to you over Skype/phone. I feel that this is really hard to explain over words. I can pay
dev 3 months ago
The rate at which syllables appear in the play function will be completely dependent on the timestamp and there is no problem in here(already solved). I am doing this way, if the user press + button then threshold increases 10ms on every press and if the user press - button then threshold increases 10ms on every press.This way the each user can set his own threshold dynamically and can use any key to enter the tap sequence. I can do this if it's okay with you and I think this is what you are trying to achieve.
Codeword 3 months ago
I guess I'll have to try it out and see if it hits my requirements. Basically, I'd be using my keyboard ("m" and "b") keys like drums to record the rhythm the bars should be displayed (syllable by syllable). Then the bars can be played exactly as the rhythm dictates. I think this is what your code does? I will have to test it to see.
dev 3 months ago
Is it possible to put this up on a fiddle?
dev 3 months ago
That's what I am trying. I will provide the solution in both method(i will create two sepearte fiddle) and then you decide which one you want to use.Alright.
Codeword 3 months ago
Works for me. You're the best
dev 3 months ago
Hey, dev this is the first method https://jsfiddle.net/fqqejavn/26/ example.Take a look, meanwhile, I create the second fiddle.
Codeword 3 months ago
Hey dav here is the second fiddle https://jsfiddle.net/vd0sp4nt/46/ take a look
Codeword 3 months ago
I don't want the user to be able to adjust thresholds - they should only have to tap out beats. I like that the second fiddle treats all keys as the same. However, it spits out whole words only. I can't get "Nobody" to show as "No" "bo" "dy" when I do a quick taptaptap
dev 3 months ago
it's working see this pic, may be you are doing it the wrong way here is the pic https://drive.google.com/open?id=0B03VR7Fad1PaZGtsZjR3TTJKVGc
Codeword 3 months ago
every thing is working fine and as far as the threshold is concerned you can hard code it if you don't want the user to be able to set it.Compare your input with the pic and see where have you made a mistake. here in the pic I have taken 1000ms as threshold(you can set a fixed value but remember this threshold is used just to know whether the user pressed tap tap seperately or taptap in a consecutive manner.Also their will be a timestamp associated with every tap may it be tap tap or taptap.) , that is if the interval between two key press is more than 1000ms(threshold) it is treated as tap tap otherwise taptap
Codeword 3 months ago
I played with the code. I messed around with different threshold levels. It's very close. However, I'm not able to get it to perfectly match the rhythm flow I want from my taps. It seems that the reason is that, when I tap, I tap out the flow syllable by syllable. Each key press represents a syllable. It doesn't matter about the threshold between key presses. Each subsequent syllable in the bar should be associated to a tap#timestamp. The play function should increase in thresholds of 10ms and display the bar syllable by syllable. The only time a full word should display at once is when it has only 1 syllable. For all words with 2 or more syllables, they should be displayed only one syllable at a time.
dev 3 months ago
Hello, dev have you tried as shown in the pic I provided above?Thank you.
Codeword 3 months ago
So here is an example: "Funky fresh in the Friday fun." becomes syllablesArray = [ "Fun", "ky", " ", "fresh", " ", "in", " ", "the", "Fri", "day"," ", "fun."] My tap sequence is: tap@Atime#tap@Btime#tap@Ctime#tap@Dtime#tap@Etime#tap@Ftime... Atime = timestamp when "Fun" was tapped Btime = timestamp when "ky" was tapped Ctime = timestamp when "fresh" was tapped ... Play sequence: interval(10ms) { go through syllables array and print each item out at the associated tap time
dev 3 months ago
Yeah I tried like that pic, but you have the threshold set at 1000ms. Nobody will wait that long between taps. It can be several taps a second. I tried several thresholds between 0 - 300ms, but none of them really fit what I wanted. Also, not everyone taps at the same speed, so the threshold changes from person to person. This is why I don't want to rely on threshold. I'd rather go with each tap representing a syllable in the bar.
dev 3 months ago
That's the problem with the second method, I was mentioning previously.In the second method If we do not use any threshold, how will the program knows whether the user want to display Nobody as whole or No bo dy. This will be no way for the program to know.
Codeword 3 months ago
Let's make the assumption that the user will always want to go syllable by syllable. So always No bo dy. However, the user wouldn't see the spaces between no, bo, and dy. The system would display No, then Nobo, then Nobody
dev 3 months ago
So any word with more than 1 syllable will always be displayed syllable by syllable
dev 3 months ago
you mean the user will enter say(input) --- I went to my car. No bo dy knows my scars(with spaces between No bo dy).Then output should be -- I went to my car. Nobody knows my scars (but displayed syllable by syllable as provide in input). This is what you want.Am I right ?
Codeword 3 months ago
No, I don't think that's right. There would still be tapping - no text input. All words are always displayed syllable by syllable. The time difference between taps drives the time difference between syllable display
dev 3 months ago
Let me create a seperate fiddle so that you can instruct me how to peoceed oaky.1 min please
Codeword 3 months ago
Hey dev, look at this fiddle https://jsfiddle.net/c8b3ajbb/6/ , up to this point everything is correct.right? what to do next tell me so that i can modifify it as we go.thank you
Codeword 3 months ago
for simplicity let's take nobody is a single syllable for now. And I went to my car. Nobody knows my scars will be displayed syllable by syllable as per the timestamp associated with each syllable as you intended. I(tap) went(tap) to(tap) my(tap) car.(tap) Nobody(tap) knows(tap) my(tap) scras.(tap) .Check if it's correct upto this point so that we can proceed next without any confusion.
Codeword 3 months ago
https://jsfiddle.net/c8b3ajbb/6/#&togetherjs=kmNCE218Js Lets collaborate via this link
dev 3 months ago
Nobody can't be associated with one syllable. Multi syllable words spread over multiple beats. Rappers use the syllables in words rhythmically,
dev 3 months ago
Dev , As npm library is concerned it uses some sort online-dictionary(to lookup word in a server) to seperate word as syllable apart form the known methods, I can write a code to seperate a word into syllable but I wouldn't be 100% correct always beacause unlike npm library we don't have a dictionary to look at . For example we can easily split say a word -- Basket as Bas ket but we will not be able to split compound words like sportscar into sports car without a dictionary. Let me know what you think.
Codeword 3 months ago
Nevertheless, I will try to come up with a solution if I can.Thank you
Codeword 3 months ago
Hi codeword, if it helps, you can assume that the array will be available and go from there. No need to recreate the syllable breaker.
dev 3 months ago
If that is the case then its easy from here.One more help please convert this I went to my car. Nobody knows my scars to array for me as reference.
Codeword 3 months ago
hey, dev for your satisfaction I've created this fiddle https://jsfiddle.net/voxzy81w/7/ where I have implemented a syllable breaker. It works but will not be 100% accurate always as I mentioned previously because unlike the NPM package we don't have an online-dictionary to check against.So You can have a look at this.At the moment it is displaying correct output and will work in some scenario.
If you are happy with this then it's great and if not then as you said We have to assume that we have the syllable array.In that case, you will have to set var finalraptext_array= [your syllable array here] this is the fiddle https://jsfiddle.net/95m4p9av/6/ for this case Thank you.
Codeword 3 months ago
Hey Codeword, I tried the first one, and it divides syllables incorrectly, so I will have to use the library. I tried "Tomas", which became "To ma s", where it should be "To mas" The library I will use spit out an array of arrays, where each sub array is the word. nlp.text('simple is different from easy').termsWithSyllables().then(terms => { const allSyllables = terms.map(t => t.syllables) console.log(JSON.stringify(allSyllables)) // output: // [ // ['sim', 'ple'], // ['is'], // ['dif', 'fer', 'ent'], // ['from'], // ['eas', 'y'] // ] }) Will your second fiddle be able to handle this kind of array? Will it be able to automatically add spaces in between the words too? And will it handle punctuation? Thanks
dev 3 months ago
offcourse let me modify the second fiddle.wait a min.Thank you
Codeword 3 months ago
Hey dev, here is the modified fiddle https://jsfiddle.net/95m4p9av/13/
Codeword 3 months ago
Hey Codeword, I see one issue. When I do tap ...... wait a couple seconds.... tap, Sim ple always comes out very quickly.
dev 3 months ago
okay let me check.
Codeword 3 months ago
Hey check this https://jsfiddle.net/95m4p9av/24/
Codeword 3 months ago
YES! IT WORKED! I am going to test it with many more use cases and get back to you. But for "simple is different from easy", it works perrrrrrrfectly!!! Stay tuned... YES!
dev 3 months ago
no problem.
Codeword 3 months ago
Great, your code is perfect. So long as the incoming final _ rap textarray is correct, the play function works. The issue now is that the library I'm using to do the syllables isn't perfect. For example, it split "boat" into 2 syllables ("bo at"), where it should just be 1 syllable ("boat"). Also, the system doesn't know how to deal with new line characters. On the site spitsomebars.com, rappers use new lines that need to be preserved. After I implement your code above, I will start a separate bounty for helping me perfect the system. This will involve an "adjustment" feature where the user can fix the finalraptext_array using some kind of input box. Also, I'll need a way to deal with new lines. Stay tuned for this bounty - I'll need your help with it! Thanks so much!
dev 3 months ago
Thank you dev.
Codeword 3 months ago
Actually, I was about to suggest you this so called "adjustment" feature as you said, where the user can edit the finalraptext after the syllable breaker has done its job.That way, what ever mistake the syllable break makes it can be rectified by the user before finally submitting it to the play function and believe me this will be required as the algorithm(even the npm package) will not always be 100% correct.
Codeword 3 months ago
Yes, this adjustment feature will be necessary. I'm thinking that the user will see pipes ("|") where the npm package split the words. The user can move or remove these pipes to adjust the syllables. What are your thoughts?
dev 3 months ago
So the user would see "bought a bo|at on tues|day" and the user can remove the | in bo|at to make it one syllable.
dev 3 months ago
Yeah, that would be better.
Codeword 3 months ago
View Timeline