Skip to content

Commit

Permalink
- Fixed non-existing pitch file problem. Now it computes the f0 conto…
Browse files Browse the repository at this point in the history
…ur if it cannot find the pitch file.

- Various minor changes in HNM TTS for debugging purposes.

git-svn-id: https://mary.opendfki.de/repos/trunk@2032 953a6561-930b-0410-b2a6-db37d1b2ae63
  • Loading branch information
Oytun Turk committed Jul 28, 2009
1 parent 85c9b3e commit 70ec4c2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 33,10 @@
import marytts.signalproc.filter.LowPassFilter;
import marytts.util.data.DoubleDataSource;
import marytts.util.data.audio.AudioDoubleDataSource;
import marytts.util.io.FileUtils;
import marytts.util.math.MathUtils;
import marytts.util.signal.SignalProcUtils;
import marytts.util.string.StringUtils;

/**
* Autocorrelation based F0 tracker with heuristic rules based on statistics for smoothing
Expand Down Expand Up @@ -66,6 68,54 @@ public class F0TrackerAutocorrelationHeuristic {
private int ws;
private int ss;

public F0TrackerAutocorrelationHeuristic(String wavFile) throws Exception
{
if (FileUtils.exists(wavFile))
{
String ptcFile = StringUtils.modifyExtension(wavFile, "ptc");

params = new PitchFileHeader();

init();

PitchReaderWriter f0 = null;
try {
f0 = pitchAnalyzeWavFile(wavFile, ptcFile);
} catch (UnsupportedAudioFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
throw new Exception("Wav file not found!");
}

public F0TrackerAutocorrelationHeuristic(String wavFile, String ptcFile) throws Exception
{
if (FileUtils.exists(wavFile))
{
params = new PitchFileHeader();

init();

PitchReaderWriter f0 = null;
try {
f0 = pitchAnalyzeWavFile(wavFile, ptcFile);
} catch (UnsupportedAudioFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
throw new Exception("Wav file not found!");
}

public F0TrackerAutocorrelationHeuristic(PitchFileHeader paramsIn)
{
params = new PitchFileHeader(paramsIn);
Expand Down
24 changes: 15 additions & 9 deletions java/marytts/signalproc/process/FDPSOLAProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 34,7 @@
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

import marytts.signalproc.analysis.F0TrackerAutocorrelationHeuristic;
import marytts.signalproc.analysis.PitchReaderWriter;
import marytts.signalproc.analysis.PitchMarks;
import marytts.signalproc.window.DynamicWindow;
Expand Down Expand Up @@ -205,12 206,6 @@ protected void init(int initialisationType, String strInputFile, String strPitch
bContinue = false;
}

if (!FileUtils.exists(strPitchFile))
{
System.out.println("Error! Pitch file " strPitchFile " not found.");
bContinue = false;
}

if (strOutputFile==null || strOutputFile=="")
{
System.out.println("Invalid output file...");
Expand All @@ -233,7 228,18 @@ protected void init(int initialisationType, String strInputFile, String strPitch

origLen = (int)input.getDataLength();
fs = (int)inputAudio.getFormat().getSampleRate();


if (!FileUtils.exists(strPitchFile))
{
System.out.println("Pitch file cannot be found, computing... " strPitchFile);
try {
F0TrackerAutocorrelationHeuristic f0Tracker = new F0TrackerAutocorrelationHeuristic(strInputFile, strPitchFile);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

PitchReaderWriter f0 = new PitchReaderWriter(strPitchFile);
pm = SignalProcUtils.pitchContour2pitchMarks(f0.contour, fs, origLen, f0.header.windowSizeInSeconds, f0.header.skipSizeInSeconds, true, 0);

Expand Down Expand Up @@ -1761,8 1767,8 @@ public static void main(String[] args) throws Exception
{
//double [] pscales = {0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.05, 1.10, 1.15, 1.20, 1.25, 1.30, 1.35, 1.40, 1.45, 1.50};
//double [] tscales = {1.50, 1.45, 1.40, 1.35, 1.30, 1.25, 1.20, 1.15, 1.10, 1.05, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.65, 0.60};
double [] pscales = {1.5};
double [] tscales = {1.5};
double [] pscales = {1.0};
double [] tscales = {1.2};
double [] escales = {1.0};
double [] vscales = {1.0};
mainParametric(args[0], pscales, tscales, escales, vscales);
Expand Down
6 changes: 3 additions & 3 deletions java/marytts/tools/voiceimport/HnmTimelineMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 298,7 @@ public boolean compute()

PitchMarks pm = new PitchMarks(pmFile, globSampleRate);
pm.findAndSetUnvoicedF0s(f0.contour, f0.header, globSampleRate);
//hnmSignal = ha.analyze(wave, wav.getSampleRate(), f0, null, analysisParams, synthesisParamsBeforeNoiseAnalysis, hnmAnalysisFile);

if (n==0)
{
f0WindowSizeInSeconds = f0.header.windowSizeInSeconds;
Expand All @@ -308,9 308,9 @@ public boolean compute()
f0SkipSizeInSeconds = f0.header.skipSizeInSeconds;
}

//hnmSignal = ha.analyze(wave, wav.getSampleRate(), pm, f0WindowSizeInSeconds, f0SkipSizeInSeconds, pm.f0s, null, analysisParams, synthesisParamsBeforeNoiseAnalysis, hnmAnalysisFile);
hnmSignal = ha.analyze(wave, wav.getSampleRate(), pm, f0WindowSizeInSeconds, f0SkipSizeInSeconds, pm.f0s, null, analysisParams, synthesisParamsBeforeNoiseAnalysis, hnmAnalysisFile);

hnmSignal = ha.analyze(wave, wav.getSampleRate(), f0, null, analysisParams, synthesisParamsBeforeNoiseAnalysis, hnmAnalysisFile);
//hnmSignal = ha.analyze(wave, wav.getSampleRate(), f0, null, analysisParams, synthesisParamsBeforeNoiseAnalysis, hnmAnalysisFile);
}

/* - For each frame in the hnm modeled speech signal: */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 101,7 @@ protected boolean readIntoBuffer(int minLength)
} else {
Datagram next = datagrams[p][q];
int length = (int) next.getDuration();
System.out.println("Unit duration = " String.valueOf(length));
//System.out.println("Unit duration = " String.valueOf(length));
if (buf.length < writePos length) {
increaseBufferSize(writePos length);
}
Expand Down
4 changes: 3 additions & 1 deletion java/marytts/unitselection/concat/HnmUnitConcatenator.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 85,8 @@ protected void getDatagramsFromTimeline(List<SelectedUnit> units) throws IOExcep
long unitStart = unitToTimeline(unit.getUnit().getStart()); // convert to timeline samples
//System.out.println("Unit size " unitSize ", pitchmarksInUnit " pitchmarksInUnit);
//System.out.println(unitStart/((float)timeline.getSampleRate()));
//System.out.println("Unit index = " unit.getUnit().getIndex());

Datagram[] datagrams = timeline.getDatagrams(unitStart,(long)unitSize);
unitData.setFrames(datagrams);

Expand Down Expand Up @@ -189,7 191,7 @@ protected BufferedDoubleDataSource synthesize(Datagram[][] datagrams, Datagram[]
deltaTimeInSeconds = ((HntmSpeechFrame)((HnmDatagram)datagrams[i][j]).getFrame()).deltaAnalysisTimeInSeconds;
originalDurationInSeconds = deltaTimeInSeconds;

System.out.println("Unit duration = " String.valueOf(length));
//System.out.println("Unit duration = " String.valueOf(length));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 54,8 @@ protected void getDatagramsFromTimeline(List<SelectedUnit> units) throws IOExcep
long unitStart = unitToTimeline(unit.getUnit().getStart()); // convert to timeline samples
//System.out.println("Unit size " unitSize ", pitchmarksInUnit " pitchmarksInUnit);
//System.out.println(unitStart/((float)timeline.getSampleRate()));
//System.out.println("Unit index = " unit.getUnit().getIndex());

Datagram[] datagrams = timeline.getDatagrams(unitStart,(long)unitSize);
unitData.setFrames(datagrams);
// one right context period for windowing:
Expand Down

0 comments on commit 70ec4c2

Please sign in to comment.