JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 voice in JAVA? [精華]
Marcoco



發文: 0
積分: 0
於 2004-01-05 02:47 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
想聽聽大家的意見。我們知道JAVA有sound API,而JMF也提供了更多的
支援,看似java在multimedia方面也逐漸投入心力,但java所寫的軟體好像
大都要先安裝JDK or JMF。我最近想用java來開發一個語音(音樂)相關的ap
,並掛成applet,但不知寫出來後是否真的實用?,在運作上是否有什麼難
行之處?,java同好歡迎分享經驗,謝謝。

p.s: 最近正在學java,希望java能達到我的需求。(不然就要回去BCB的懷抱
了~我不想)


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
alin





發文: 223
積分: 3
於 2004-01-05 10:07 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
語音相關??
哪一方面的?

我看過有用Java寫成Applet的MP3 player、Sound Recorder、Sound Player...

基本上, 開發應該不是大問題, 比較大的困難是在於, 你怎麼確保客戶端的環境符合你的Applet的需求?

另一點是, 這些Sound的實做,勢必須要用到客戶端的資源(Speaker), 所以, 你要怎麼說服客戶相信你的Aplpet的安全性問題.


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
marcococo



發文: 0
積分: 0
於 2004-01-05 15:51 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
嗯...我想弄的是單純的...錄音->丟進辨識engine->結果查尋db->show結果...
applet的話...放在自己的server上然後安全自己控管!?...

你說的Sound Recorder我知道...我玩過trial版...不過限錄四分鐘...
我倒比較在意環境的問題...似乎至少必須安裝JRE才能run...is it?


reply to postreply to post
作者 Re:voice in JAVA? [Re:marcococo]
alin





發文: 223
積分: 3
於 2004-01-05 18:28 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我是自己開發的錄音程式
大部分都是套用JMF的東西

JVM阿, 那是一定要的啦, 不過用HtmlConverter轉一次之後, 就萬事OK啦


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
Marcoco



發文: 0
積分: 0
於 2004-01-06 01:39 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
耶!?這麼巧...你也在弄錄音程式...不知你做的如何?...我最近是在看
javax.sound.*的東西...不過doc還沒k完...不是很好懂....有人用過java
sound api寫過voice相關的程式嗎?....我想跟他討教一下...

alin對JMF熟嗎?...錄音程式寫的如何...用JMF比Sound API方便嗎?...若可
以的話想分享一下你寫錄音程式的經驗...多謝


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
alin





發文: 223
積分: 3
於 2004-01-06 02:29 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我想我們都是在用同樣的東西吧 ASR、VXML.....
在JMF的套件裡面, 下載回來解開後, 我記得有一些範例,
當初我的錄音程式就是先從那一部份先改出來的
而後在加上Web-Server和Applet之間的傳輸問題就都解決了

當初我使用的版本無法儲存成我想要的格式....所以又做了一些手腳....

這個拼湊成的錄音程式目前是在等待要上線的狀態
等同事測的滿意了, 我就解脫了 Smile


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
marcococo



發文: 0
積分: 0
於 2004-01-06 13:46 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
呵呵..要上線啦...感覺不賴...我還是先用java sound api熟悉一下java對
音訊的處理吧...

下面這個站有不少資源和source code可以練習....
http://www.jsresources.org/examples/

不知alin是否做語音相關的工作...有機會希望能夠討教一下...
my msn messenger: mi88008@mi.chu.edu.tw
thx~


reply to postreply to post
作者 Re:voice in JAVA? [Re:marcococo]
alin





發文: 223
積分: 3
於 2004-01-06 14:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Java Recorder的範例靈感來自於
http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/

裡面的Demo程式有一個Panel是用來做Record/Play音檔的

看看合不合用吧


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
alin





發文: 223
積分: 3
於 2004-07-21 11:30 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
chuang5089 ask:

Can i ask some java sound quest ..

Do you have any idea for my question

1. record sound from java api
2. play sound from java api
3. something like record sound by mic on thread 2000 second and play it,
like i can use inputstream method record sound and outputstream methoud play just what i say from mic

4. 1 and 2 condiction without use create file

Best regard

---- 分隔線 ---- 分隔線 ---- 分隔線 ----

基本上, 你可以使用 JDK 1.4 裡的 javax.sound.sampled 套件來達到簡單的錄音然後再播放的功能

錄音和放音的功能需要用到的幾個主要Class有以下幾個

javax.sound.sampled.AudioFormat
設定錄音的線路要路程什麼格式

javax.sound.sampled.AudioInputStream
AudioInputStream 繼承自InputStream, 基本上就是一個串流的輸入

javax.sound.sampled.AudioSystem
可以透過這一個物件去取得系統中可供使用的硬體有哪些

javax.sound.sampled.TargetDataLine
可以透過 TargetDataLine 取得有哪些可供錄音的線路存在

javax.sound.sampled.SourceDataLine
可以透過 SourceDataLine 取得有哪些可供播音的線路存在

下面節錄自 JDK /demo的一小段錄音部分的範例程式
(下載位置http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
      AudioFormat format = formatControls.getFormat();
      DataLine.Info info = new DataLine.Info( TargetDataLine.class, format );
 
      AudioFormat[] afs = info.getFormats();
      System.out.println("Support formating recording folowing.......\r\n");
      for (int i = 0; i < afs.length; i++) {
        System.out.println("afs["+i+"]=" + afs[i].toString());
      }
 
      if ( !AudioSystem.isLineSupported( info ) ) {
        shutDown( "Line matching " + info + " not supported." );
        return;
      }
 
      // get and open the target data line for capture.
      try {
        line = ( TargetDataLine ) AudioSystem.getLine( info );
        line.open( format, line.getBufferSize() );
      }
      catch ( LineUnavailableException ex ) {
        shutDown( "Unable to open the line: " + ex );
        return;
      }
      catch ( SecurityException ex ) {
        shutDown( ex.toString() );
        showInfoDialog();
        return;
      }
      catch ( Exception ex ) {
        shutDown( ex.toString() );
        return;
      }
 
      // play back the captured audio data
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      int frameSizeInBytes = format.getFrameSize();
      int bufferLengthInFrames = line.getBufferSize() / 8;
      int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
      byte[] data = new byte[bufferLengthInBytes];
      int numBytesRead;
 
      line.start();
 
      while ( thread != null ) {
        if ( ( numBytesRead = line.read( data, 0, bufferLengthInBytes ) ) == -1 ) {
          break;
        }
        out.write( data, 0, numBytesRead );
      }
 
      // we reached the end of the stream.  stop and close the line.
      line.stop();
      line.close();
      line = null;
 
      // stop and close the output stream
      try {
        out.flush();
        out.close();
      }
      catch ( IOException ex ) {
        System.out.println( "run() CapturePanel error : " + ex.getMessage() );
      }
 
      // load bytes into the audio input stream for playback
 
      byte audioBytes[] = out.toByteArray();
      ByteArrayInputStream bais = new ByteArrayInputStream( audioBytes );
      audioInputStream = new AudioInputStream( bais, format,
                                               audioBytes.length / 
                                               frameSizeInBytes );
 
      long milliseconds = ( long ) ( ( audioInputStream.getFrameLength() * 1000 ) / 
                                     format.getFrameRate() );
      duration = milliseconds / 1000.0;
 
      try {
        audioInputStream.reset();
      }
      catch ( Exception ex ) {
        System.out.println( "reset error : " + ex.getMessage() );
        return;
      }


裡面主要在做的事情就是
1.先確定音檔格式
2.找到相關的硬體資料
3.透過 ( TargetDataLine ) AudioSystem.getLine( info ); 取得一個可以錄音的線路
4.取得線路後, 可以將 TargetDataLine 這一個物件, 看做和 File 一樣的物件 (類似啦~)
這時錄音開始的時候, 聲音的輸入將會視作一般的 InputStream 放在線路的Buffer中
然後, 再用 ByteArrayPutputStream 將 線路中的 InputStream 取出來, 轉換成AudioInputStream 即可

假如想要將 AudioInputStream 裡面的資料及時播放出來, 需要做像上述的動作
就是先取得 AudioFormat, 取得播音的線路 (SourceDataLine), 檢查播音線路是否支援欲播放的格式
假如可以救播放

先說到這裡吧, 因為需要處理的物件實在太多了, 所以無法一一說明, 建議先去把範例程式下載回來, 跑個幾遍
有問題時我們再來慢慢討論, ok?


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
ggx





發文: 3
積分: 0
於 2004-09-04 22:46 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問個位大大~~~
如果要將聲音剪輯,該如何做到呢?

ps:我指的聲音是指一般的wav檔,或是使用者錄下來的聲音!


reply to postreply to post
作者 Re:voice in JAVA? [Re:alin]
srvrv12





發文: 6
積分: 0
於 2007-01-26 17:21 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問一下
我下載了JavaSound Demo 的源始碼,試著去錄音
錄完音後卻無法聽到聲音,

請問我是否要在程式中指定錄音的來源,請問若要的話如何指定

謝謝~~


reply to postreply to post
作者 Re:voice in JAVA? [Re:srvrv12]
alin





發文: 223
積分: 3
於 2007-01-26 17:53 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
剛剛下載跑了一遍, 發現不用設定就全都正常

是不是先開啟其他程式, 確定機器上的錄音設備沒問題??


reply to postreply to post
作者 Re:voice in JAVA? [Re:Marcoco]
clairechuang





發文: 4
積分: 0
於 2009-04-30 18:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問一下,是否有人做過或看過wav player可以自定播放區間做播放
類似可以拉音檔的一部份做播放..
如下面這個
http://www.javasonics.com/listenup/examples/play_welcome.html

可否指點方向.謝謝


reply to postreply to post
» JWorld@TW »  Java SE 討論區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8