|
|
i want to implement text to speech converter in java. how to do that? can i do it using core java or do i need advanced java to implement it?
i m having it as a final year project.
|
|
|
|
|
start making a concept - most times this helps me a lot.
"text to speech" means you want to convert written text into audio? What kind of text? You will need a person with a clear, smart voice (probably a woman).
greets
Torsten
I never finish anyth...
|
|
|
|
|
|
Hey guys! So I've been trying to get this utility method to work for a while and can't seem to stop overloading the stack. The method should be able to emulate the Paint Can Tool in MS Paint. It takes a BufferedImage, the x- and y-coordinates of the point to apply the method to, and the color with which to paint the area. My implementation is a recursive one, and I know this is the reason for the overflow, but I haven't done any complex recursive method writing as of yet and don't know how I can fix my problem. Here is the code I've written:
static void paintCan(BufferedImage image, int x, int y, Color color) {
int[][] array = new int[image.getWidth()][image.getHeight()];
for (int r = 0; r < image.getHeight(); r++)
for (int c = 0; c < image.getWidth(); c++)
array[c][r] = image.getRGB(c, r);
changeColor(array, x, y, array[x][y], color.getRGB());
for (int r = 0; r < image.getHeight(); r++)
for (int c = 0; c < image.getWidth(); c++)
image.setRGB(c, r, array[c][r]);
}
static void changeColor(int[][] image, int x, int y, int from, int to) {
if (image[x][y] == from) {
image[x][y] = to;
int left = x - 1;
int right = x + 1;
int up = y - 1;
int down= y + 1;
if (left >= 0)
changeColor(image, left, y, from, to);
if (right < image.length)
changeColor(image, right, y, from, to);
if (up >= 0)
changeColor(image, x, up, from, to);
if (down < image[0].length)
changeColor(image, x, down, from, to);
}
}
This method works perfectly for smaller areas, but when the area selected at the (x, y) point requires too much recursion, a runtime error is thrown. Does anyone know how I can get the method to use less memory and not overload the stack? Help is very appreciated Thank you!
-max
|
|
|
|
|
I did some testing with your code and here are my results:
1. Image size does not effect result.
2. The Pixels in your image cause the stack overflow.
- When your image is mono colored.
- When your image contain n colors in shapes lets say black square, green circle etc...
The above throw the Exception
- When approximately all pixels of the image vary then your code works fine with any size even with 1920 x 1080.
If you want to use the bucket feature in MS Paint here is a simpler way:
BufferedImage image = ImageIO.read(new File("Desert.jpg"));
Color c = Color.red;
int x0 = 10,x1 = 100,y0 = 10,y1 = 100;
for (int i = x0; i < x1; i++)
{
for (int j = y0; j < y1; j++)
{
image.setRGB(i, j, c.getRGB());
}
}
ImageIO.write(image, "jpg", new File("Result.jpg"));
By the way the recursion problem is in the change color method.
Hope this help
|
|
|
|
|
I was aware that it was not the image size, but the number of pixels in the shape being filled that was the problem, and that the recursion overflow error was occurring in the changeColor() method... Your solution does not implement the bucket feature in MS Paint, because when you use the paint bucket in Paint it fills all adjacent pixels of a similar color with the color of your choice, what you have given me only fills a rectangle with a certain color :/
Thanks for the reply though!
|
|
|
|
|
I think I found the answer guys. My main problem for looking for help with my problem was that I didn't know what the "paint can tool" functionality was called! But it turns out there is something called the Flood Fill Algorithm that is exactly what I'm talking about implementing.
http://en.wikipedia.org/wiki/Flood_fill[^]
|
|
|
|
|
My bad, in my way I was trying to say that if you give the coordinates of the pixels then use the graphics class to fill in the color but its not practical any way here is a nice implementation of the specified algorithm: http://www.cis.upenn.edu/~matuszek/cit594-2005/ Check FloodFillApplet.java and ColorArrayComponent.java
Good luck
|
|
|
|
|
|
how to devlop TAPI in java. i want to devlop TAPI in java and use this interface in ASP.Net application to devlop a virtual phone.
|
|
|
|
|
I personally haven't done Tapi programming but from what I searched you can do it solely using ASP.NET
http://www.julmar.com/blog/mark/PermaLink,guid,0535ed97-f590-438e-9b99-1ddee1e8237a.aspx (you require the Atapi.dll from http://www.julmar.com/tapi/)
I also found this (JTapi) http://xtapi.sourceforge.net/ and http://blog.devrealm.org/2009/03/26/jtapi-overview/ You can convert the classes to applets and embed them in your ASP.NET application but I think if you can get the first link to work that would save you a lot of time.
Good Luck
|
|
|
|
|
Hi all,
am an entirely a newbie in encryption, just decided to give it a go with a book. But a lost at trying to configure my machine to run simple encryption codes, like the one given below; running with a 128-byte array size works fine but i dont know how i can implement the 256-byte or 192-byte array key size.
I've replaced the "strong Encryption" policy in JRE in Java path with unrestricted policy jar files i downloaded from Sun website.
Also i used the bounty Castle provider and copied the jar files to "ext" sub-directory in Jre directories.
Yet it does'nt seem to work perfectly.
Any Idea would be greatly appreciated.
Thanks alot in advance!!
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
public class EncryptTest {
public EncryptTest()
{
}
public static void main(String[] args) throws Exception
{
KeyGenerator keygen = KeyGenerator.getInstance("AES");
keygen.init(192);
SecretKey aesKey = keygen.generateKey();
Cipher aesCipher;
aesCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
aesCipher.init(Cipher.ENCRYPT_MODE, aesKey);
byte[] clearText = "This is an example!".getBytes();
System.out.println("ClearText: "+new String(clearText));
byte[] cipherText = aesCipher.doFinal(clearText);
System.out.println("CipherText: "+new String(cipherText));
aesCipher.init(Cipher.DECRYPT_MODE, aesKey);
byte[] clearTextDecrypt = aesCipher.doFinal(cipherText);
System.out.println("DecryptedText: " + new String(clearTextDecrypt));
boolean equalText = Arrays.equals(clearText, clearTextDecrypt);
if (equalText)
{
System.out.println("Successful recovery!");
}
else
{
System.out.println("String was NOT recovered!!");
}
}
}
|
|
|
|
|
Your code will run fine but you need to tweek your JDk and JRE.
1. Go to http://java.sun.com/javase/downloads/index.jsp and download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6.
2. In these directories C:\Program Files\Java\jdk1.6.0_16\jre\lib\security and C:\Program Files\Java\jre6\lib\security
3. Paste the two jars you downloaded and everything will work.
Regards
|
|
|
|
|
Thanks Member 4277480 for ur reply, but i did the same with jdk1.5_20 and did exactly what u said, but it isn't working for me.
Any other thing I should do?
Thanks again!!
|
|
|
|
|
Upgrade to 6u16! Always use latest JDK.
|
|
|
|
|
I will try just that and then c how it works.
I will give u a feed back later!
Thanks!
|
|
|
|
|
Thanks a lot Member, ur advice worked perfectly!
I'll now enjoy enciphering and deciphering I guess!!!
Thanks!
|
|
|
|
|
Good to hear your progress
|
|
|
|
|
Hi everybody !
Im now using TrayIcon . The tooltip message display two caption and the image belong to Message Type as bellow.
-Title :String
-Message :String.
-MessageType:INFO,WARNING,ERROR,NONE.
I now want to dis play the tooltip message with two caption and the Icon image that i specify the path as bellow:
-Title :String
-Message :String.
-IconImage : IconImage or path of the image.
Can anybody help me.
Thanks very much !
Best regards !
|
|
|
|
|
In short if the TrayIcon class was a JComponent then you can simply apply html tags to it. Therefore, to simulate what you need I will use the jdic.jar from https://jdic.dev.java.net/servlets/ProjectDocumentList?expandFolder=4183&folderID=5497.
import javax.swing.*;
import org.jdesktop.jdic.tray.*;
import java.awt.BorderLayout;
import java.awt.event.*;
public class SystemTrayDemo extends JFrame
{
public TrayIcon trayIcon;
public JDialog dialog;
public SystemTrayDemo()
{
JPopupMenu menu = new JPopupMenu("Menu");
JMenuItem menuItem1 = new JMenuItem("Menu1");
menu.add(menuItem1);
JMenuItem menuItem2 = new JMenuItem("Menu2");
menu.add(menuItem2);
JMenuItem menuItem3 = new JMenuItem("Menu3");
menu.add(menuItem3);
JMenuItem menuItem4 = new JMenuItem("Exit");
menu.add(menuItem4);
menuItem4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
System.exit(0);
}
});
ImageIcon icon = new ImageIcon("middle.gif");
trayIcon = new TrayIcon(icon, "Hello System Tray", menu);
SystemTray tray = SystemTray.getDefaultSystemTray();
tray.addTrayIcon(trayIcon);
trayIcon.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dialog = new JDialog();
dialog.add(new JLabel("Title"), BorderLayout.NORTH);
dialog.add(new JLabel("Message"), BorderLayout.CENTER);
dialog.add(new JLabel(new ImageIcon("middle.gif")),BorderLayout.SOUTH);
dialog.setLocation(trayIcon.getLocationOnScreen().x - 50,trayIcon.getLocationOnScreen().y - 105);
dialog.setVisible(true);
dialog.setSize(100, 100);
dialog.setResizable(false);
dialog.addMouseListener(new MouseAdapter()
{
public void mouseReleased(MouseEvent e)
{
dialog.dispose();
}
});
}
});
}
public static void main(String[] args)
{
new SystemTrayDemo();
}
}
The presentation of it is close to aero peek in windows 7.
Hope this helps.
Regards
|
|
|
|
|
Hi !
I think you didn't understand my question.
I want to display the IconImage on the top-left of the title .
For example,
trayIcon = new TrayIcon(icon, "Hello System Tray", menu);
must be change to
trayIcon = new TrayIcon(icon, "<img src="image.gif">Hello System Tray",menu);
if we can use html tags in our code !
Thanks anyways !
Can anybody help me ?
Best regards !
|
|
|
|
|
I understood your question, if you read my first line "If the trayicon class was a Jcomponent then we can use html tags". You can display (as a balloon) the message type error,info,etc... use these in place of the dialog code depending on type:
trayIcon.displayMessage("Title", "Message", trayIcon.INFO_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.NONE_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.WARNING_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.ERROR_MESSAGE_TYPE);
otherwise what your asking can only be done if you write your own package.
Regards
|
|
|
|
|
If using a JDialog or JFrame or JPanel to display an image(instead of the tooltip of TrayIcon) i think it is very simple and i didn't post my question.
I posted this question because i saw the "beautiful tooltip" of trayIcon of windowXP "your computer might be at risk". The Iconimage of the tooltip is not in (WARNING,INFO,ERROR,NONE) images.
I'm waiting for a solution for this because Microsoft did it !
Any other ideas ?
Best regards !
modified on Friday, September 11, 2009 12:42 AM
|
|
|
|
|
I was cruising around to see if their is any third party packages that can do what your asking and I stumbled upon an article on codeproject.com but its not in Java its using windows pressentation foundation but it does exaclty what you ask:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
All you need now is to get Visual C# express and get the risk icon (what i did in windows 7 rc go to windows firewall and click on turn of firewall you will get the red x snap it using the snap tool and go to photoshop to do some editing and you can then save it as 16 x 16 icon and name it Inactive.ico) then copy it and place it in the c:\...wpf-notifyicon\Sample Project\Icons folder, then rebuild the code and run, you will find at the bottom right corner custom notification message.
Hope this helps. I will try to ask sun about it but you said it your self Microsoft did it with their language not Java
Regards
|
|
|
|
|