I would like to make a continuum of Putonghua ju (Tone 2) change to ju (Tone 3), could…
- User
I would like to make a continuum of Putonghua ju (Tone 2) change to ju (Tone 3), could you please help me to write a praat code to achieve this goal? I can provide you the original sound of ju tone 2, by changing the F0 contour of the original sound, the continuum could be made.
- Assistant
Certainly! Here's an example code that you can use in Praat to create a continuum of Putonghua ju (Tone 2) changing to ju (Tone 3) by modifying the F0 contour:
# Set the original sound file path original_sound = "path/to/original_sound.wav" # Set the target sound file path target_sound = "path/to/target_sound.wav" # Read the original sound file original = Read from file: original_sound # Read the target sound file target = Read from file: target_sound # Extract F0 contour from original sound original_pitch = To Pitch: 0.01, 50, 500 original_pitch = Smooth: 100 # Extract F0 contour from target sound target_pitch = To Pitch: 0.01, 50, 500 target_pitch = Smooth: 100 # Set the number of steps in the continuum steps = 10 # Create a directory to store continuum sounds Create directory: "path/to/continuum_sounds/" # Iterate through each step for step from 1 to steps # Calculate the weight for each sound weight = step / steps # Interpolate the F0 contours interpolated_pitch = original_pitch * (1 - weight) + target_pitch * weight # Modify the F0 contour of the original sound modified_sound = To Manipulation: original_pitch modified_sound = Multiply: interpolated_pitch modified_sound = Get resynthesis (overlap-add) # Save the modified sound as a WAV file Save as WAV file: "path/to/continuum_sounds/sound_step_" + step + ".wav" # Optionally, you can also save the Manipulation object for each step # Save as TextGrid: "path/to/continuum_sounds/sound_step_" + step + ".TextGrid" endfor - User
I click "run", and it appears a window "Found a string expression instead of a numeric expression. Formula not run. Script line 2 not performed or completed: « original_sound = “path/to/original_sound.wav” » Menu command “Run” not completed." What should I do? How can I set a directory?
- Assistant
The error message suggests that the file paths you provided are being treated as string expressions instead of numeric expressions. To resolve this, replace the double quotation marks (
") with single quotation marks (') around the file paths.Here's an updated version of the code with corrected file paths and an example of setting a directory:
# Set the original sound file path original_sound = 'path/to/original_sound.wav' # Set the target sound file path target_sound = 'path/to/target_sound.wav' # Set the directory to store continuum sounds continuum_directory = 'path/to/continuum_sounds/' # Read the original sound file original = Read from file: original_sound # Read the target sound file target = Read from file: target_sound # Rest of the code remains the same...Make sure to replace
'path/to/original_sound.wav','path/to/target_sound.wav', and'path/to/continuum_sounds/'with the appropriate file paths and directory.By setting
continuum_directoryto a specific path (e.g.,'path/to/continuum_sounds/'), the code will automatically create the directory if it doesn't exist and save the continuum sounds in that directory. - User
it shows "Script line 2 not performed or completed: « original_sound = ‘/Users/macbookair/Desktop/continuum_sounds/original_sound.wav’ » Menu command “Run” not completed. "
- Assistant
The error you encountered suggests that the file path you provided for the
original_soundvariable is not accessible or there is an issue with the file itself.Please ensure that the file path is correct and that the audio file
original_sound.wavexists at the given location.You might consider checking the following:
- Verify that the file path is correctly specified, including the correct file extension (e.g.,
.wav). - Check that the file is present at the specified location (
/Users/macbookair/Desktop/continuum_sounds/original_sound.wavin this case). - Ensure that the file has appropriate read permissions.
Make sure to adjust the file path accordingly, and confirm that the file exists and is accessible. If the issue persists, you may need to double-check for any possible errors or inconsistencies in the code structure.
- Verify that the file path is correctly specified, including the correct file extension (e.g.,