• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Voice in a program

 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a program which does some thing like this.
when you enter 10.39 it gives Ten point three nine in a text area,
I use an array to get the strings. I just want to know can i store voice fragements in an array, or how can i do it so when you enter 10.39 it will say "ten point three nine".
Thank you in advance.........
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can certainly store individual sound files for the digits and play them back to create the effect you want. You might look at the Java Madia Framework to do this from an application. From a browser-based applet, you can just use the java.applet.AudioClip class and the Applet.getAudioClip() method to do the same thing. There are several examples in the %JDKHOME%\demo\applets subdirectory of your JDK installation that use sound.
Note that JMF is fairly complicated, and if you're a Java beginner, you probably want to stay away from it for now.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the reply. I can't be considered as a beginer. A little bit expreienced and very adicted to programming so hopefully I will be able to get to done.
Thank you for the reply...
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,
Since this *is* the beginner forum, I think it's OK to talk about sound, but only at the basic level. Unfortunately, if you want to use the JavaSound API (standard part of J2SE since 1.3), it's a little more involved than using the Applet sound capability. But it's very powerful, and if you just copy and paste the code right now without trying to understand it, it *will* play your sound file. I'm going to assume it is a standard .aif. You can use other formats, but some of them require a little processing. So this example assumes a standard .aif file in the same directory where this class is...

I think playing with sound is fun. I'm *not* very familiar with the sampled audio part of the API... the JavaSound API comes in two parts: sampled audio (to play things like .aif files, as well as record in.) and MIDI audio, which I'm much more familiar with (lets you create and play MIDI files). In Head First Java, there's an exercise to build a MIDI drum machine.
Cheers and good luck,
Kathy
p.s. please post your code here when you get something working. A very simple app that can play back based on the value of a text field or something would be fun.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Thank you for all the replies. According to my requirement, I think I am not able to do from the details provided from you. The thing is I have written a program which will give a 'String representaion of the Numeric value'. for example if the user enters 10.5, the program will display "Ten point five".
Now I want to improve my program to, when a user enters '10.5', the program will play a sound clip which says "Ten point five".
If you get what I mean , please help me.
Thank you.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could likely take Kathy's example, apply a big ol' switch construct a la the Cattle Drive's Assignment 4b and get it to work just fine.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I think Dirk Schreckmann didn't get what I said.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
Thank you for the reply. But I think Dirk Schreckmann didn't get what I said, I already have done the program. What I want to know is how to add sound so it will not show, but will SAY 'ten point zero' some thing like that.
Hope you got it.
Thank you again for the reply.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both I and Dirk understand exactly what you said.
Kathy showed you how to play one sound file. All you need to do is invoke that code appropriately.
Version 1:
You need to create eleven sound files: ten containing your voice saying each digit, and one saying "point". Then, when you need to say "nine point four", use Kathy's code to play the file for "nine", the file for "point", and the file for "four".
Version 2:
The last version wouldn't say "ten point four", it would say "one zero point four." So now you need to make sound files for "ten", "eleven", "twelve"... "nineteen", "twenty", "thirty", "fourty", etc. Then, again, just use Kathy's code to play the right sound files in order to compose the numbers.
Version 3:
Add even more sound files: "hundred", "thousand", "million", etc.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, I am the one who played the fool. I didn't read the program. Any way thank you very much for the reply. Certainly I will check the programs.
Thanks
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic