views:

67

answers:

2

After having some fun in a chatbox on a certain website I had an interesting idea. What would be an algorithm that, given some input text, would generate an "echo" text from it. That is, it generates the echo that you would hear if you shouted the input text in a large empty cave. For example:

Input text: Hello!
Output text: Hello!
             ello!
             lo!
             o!

The problem is I don't exactly know what I want myself. I have no idea on how to create such an algorithm or what would even be a criteria to determine if it's a good algorithm. But I suppose the general idea is clear, so I'd like to hear your thoughts.

You don't have to give a complete solution in your answers. Hints of the direction too look in, or just random thoughts about the problem are welcome too.

+3  A: 

Bad but fun (imo) solution:

Run the input through a speech synthesizer to generate a waveform. Run that waveform through an echo generator in a sound processing library. Then run the resulting waveform through a speech recognition program.

jball
Kudos for the idea, although I doubt it would result in anything remotely usable. :P
Vilx-
@jball- Can u provide brief idea about speech synthesizer. I dont know about it. Does it generate an actual sound waveform i.e. any sound file ?
Shantanu Gupta
jball
+1  A: 

You could create an array of characters, and then interate over the list of characters, using a different starting point for each iteration.

For example in C#

string Mystring = "Is There an Echo in Here?";
        char[] charArray = Mystring.ToCharArray();
        int k = 0;
        string Echo = "";
        for (int i = 0; i < (charArray.Length / 3) + 1; i++)
        {
            for (int j = k; i < charArray.Length; i++)
            {
                Echo += charArray[j];
            }
            Echo += Environment.NewLine;
            k += 3;
        }

Should produce an output something like this
Is there an Echo in Here?
there an Echo in here?
re an Echo in here?
an Echo in Here?
Echo in Here?
o in Here?
n Here?
ere?
?

Just one possible way of doing things, and you can play around with the values to change the echo effect.

Another solution would be to split the string by the words rather than characters

string Mystring = "Is There an Echo in Here?";
        string[] Words = Mystring.Split(' ');
        int k = 0;
        string Echo = "";
        for (int i = 0; i < Words.Length / 2; i++)
        {
            for (int j = k; i < Mystring.Length; i++)
            {
                Echo += Mystring[j];
            }
            Echo += Environment.NewLine;
            k += 2;
        }

Would produce the following
Is there an Echo in Here?
an Echo in Here?
in Here?

Aaron M
And how would I determine the starting point for each iteration? And what would I do in each iteration?
Vilx-