# Record Assets

This section describes API calls to upload your own content to Misty.

### **SaveImage**

Saves an image to Misty. Optionally, proportionately reduces the size of the saved image.

Valid image file types are `.jpg`, `.jpeg`, `.gif`, `.png`. Maximum file size is 3 MB.

**Example Code**

{% hint style="success" %}

```python
misty.save_image("myimage.jpg","30,190,40,24,...",300, 300, false, true)
```

{% endhint %}

**Note:** Images can be reduced in size but not enlarged. Because Misty does not adjust the proportions of images, for best results use an image with proportions similar to her screen (480 x 272 pixels).

**Parameters**

{% code overflow="wrap" %}

```python
misty.save_image(self, fileName : str = None, data : str = None, width : int = None, height : int = None, immediatelyApply : bool = None, overwriteExisting : bool = None)
```

{% endcode %}

* FileName (string) - The name of the image file to upload.
* Data (string) - The image data, passed as a base64 string. You must either supply a value for `Data` **or** specify a `File` to upload.
* File (object) - The image file to save to Misty. Valid image file types are `jpg`, `.jpeg`, `.gif`, and `.png`. **Note:** Make sure to set the content-type in the header of the POST call to `multipart/form-data`. Uploading files to Misty this way does not work with JQuery's AJAX, but does work with XHR (XMLHttpRequest). You must either supply a value for `Data` **or** specify a `File` to upload.
* Width (integer) - Optional. A whole number greater than 0 specifying the desired image width (in pixels). **Important:** To reduce the size of an image you must supply values for both `Width` and `Height`. Note that if you supply disproportionate values for `Width` and `Height`, the system uses the proportionately smaller of the two values to resize the image.
* Height (integer) - Optional. A whole number greater than 0 specifying the desired image height (in pixels). **Important:** To reduce the size of an image you must supply values for both `Width` and `Height`. Note that if you supply disproportionate values for `Width` and `Height`, the system uses the proportionately smaller of the two values to resize the image.
* ImmediatelyApply (boolean) - Optional. A value of `true` tells Misty to immediately display the uploaded image file, while a value of `false` tells Misty not to display the image.
* OverwriteExisting (boolean) - Optional. A value of `true` means the uploaded file should overwrite a file with the same name, if one currently exists on Misty. A value of `false` means the uploaded file should not overwrite any existing files on Misty

### **SaveVideo**

Saves a video to Misty.

Accepted video file types are `.mp4` and `.wmv`. Maximum file size is 6 MB.

**Example Code**

{% hint style="success" %}

```python
misty.save_video("myhomevideo.mp4","30,190,40,24,...", false, true)
```

{% endhint %}

**Parameters**

{% code overflow="wrap" %}

```python
misty.save_video(self, fileName : str = None, data : str = None, immediatelyApply : bool = None, overwriteExisting : bool = None)
```

{% endcode %}

* FileName (string) - The name of the video file to upload, with the file type extension.
* Data (string or file) - **Option 1**: A Base64-encoded string of the video file data. **Option 2**: The video file. Valid video file types are `.mp4` and `.wmv`. When using option 2, make sure to set the `content-type` in the header of the `POST` call to `multipart/form-data`. Uploading files to Misty this way does not work with JQuery's AJAX, but does work with XHR (XMLHttpRequest).
* ImmediatelyApply (boolean) - Optional. A value of `true` tells Misty to immediately play the uploaded video, while a value of `false` tells Misty not to play the video.
* OverwriteExisting (boolean) - Optional. A value of `true` means the uploaded file should overwrite a file with the same name, if one currently exists on Misty. A value of false means the uploaded file should not overwrite any existing files on Misty.

### **SaveAudio**

Saves an audio file to Misty. Maximum size is 3 MB.

Accepts audio files formatted as `.wav`, .`mp3` ,`.wma`, and `.aac`.

**Example Code**

{% hint style="success" %}

<pre class="language-python"><code class="lang-python"><strong>misty.save_audio("example.wav", "34,88,90,49,56", false, true)
</strong></code></pre>

{% endhint %}

**Parameters**

{% code overflow="wrap" %}

```python
misty.save_audio(self, fileName : str = None, data : str = None, immediatelyApply : bool = None, overwriteExisting : bool = None)
```

{% endcode %}

* FileName (string) - The name of the audio file to upload.
* Data (string) - The audio data, passed as a string containing base64 data. You must either supply a value for `Data` **or** specify a `File` to upload.
* File (object) - The audio file to save to Misty. Valid audio file types are `.wav`, `.mp3`, `.wma`, and `.aac`. **Note:** If uploading a file instead base64 data for the asset, make sure to set the `content-type` in the header of the POST call to [`multipart/form-data`](https://developer.mozilla.org/en-US/docs/web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data). Uploading files to Misty this way does *not* work with JQuery's AJAX, but does work with XHR (XMLHttpRequest). You must either supply a value for `Data` **or** specify a `File` to upload.
* ImmediatelyApply (boolean) - Optional. A value of `true` tells Misty to immediately play the uploaded audio file, while a value of `false` tells Misty not to play the file.
* OverwriteExisting (boolean) - Optional. A value of `true` means the uploaded file should overwrite a file with the same name, if one currently exists on Misty. A value of `false` means the uploaded file should not overwrite any existing files on Misty.

### **TakePicture**

Takes a picture with Misty's RGB camera. Optionally, saves the picture to Misty's local storage.

Valid resolutions (as `Width` x `Height`) for taking pictures are: 4160 x 3120, 3840 x 2160, 3264 x 2448, 3200 x 2400, 2592 x 1944, 2048 x 1536, 1920 x 1080, 1600 x 1200, 1440 x 1080, 1280 x 960, 1024 x 768, 800 x 600, 640 x 480, and 320 x 240.

These width and height values are reversed for the actual image that Misty returns when you call this command. The pictures Misty takes with her RGB camera are rotated 90 degrees counterclockwise. Misty reorients each picture 90 degrees clockwise during the encoding process.

**Example Code**

{% hint style="success" %}

```python
misty.take_picture("true","mypicture", 800, 600,"true","false")
```

{% endhint %}

**Parameters**

{% code overflow="wrap" %}

```python
misty.take_picture(self, base64 : bool = None, fileName : str = None, width : int = None, height : int = None, displayOnScreen : bool = None, overwriteExisting : bool = None)
```

{% endcode %}

* Base64 (boolean) - Sending a request with `true` returns the image data as a downloadable Base64 string, while sending a request of `false` displays the photo in your browser or REST client immediately after it is taken. Default is `false`.
* FileName (string) - Optional. The filename to assign to the image file for the captured photo. If you do not supply a filename, Misty does not save the photo.
* Width (integer) - Optional. The desired image width (in pixels). When you specify a resolution, you must pass in values for both width and height. See the command description for a list of valid resolutions.
* Height (integer) - Optional. The desired image height (in pixels). When you specify a resolution, you must pass in values for both width and height. See the command description for a list of valid resolutions.
* DisplayOnScreen (boolean) - Optional. If `true` **and** a `FileName` is provided, displays the captured photo on Misty's screen. If `false` or no `FileName` value is provided, does nothing.
* OverwriteExisting (boolean) - Optional. Indicates whether Misty should overwrite an image with the same filename as the captured photo if one exists on her local storage. Passing in `true` overwrites a file with the same name. Passing in `false` prevents an existing file with the same name from being overwritten. In the case that `OverwriteExisting` is set to `false` and a photo already exists with the same filename as the newly captured photo, the new photo is not saved to Misty. Defaults to `false`.

### **StartRecordingAudio**

Starts Misty recording audio. Misty saves audio recordings to her local storage as .wav files. To stop recording, you must call the `StopRecordingAudio` command.

**Important!** If you do not issue a `StopRecordingAudio` command, Misty will continue recording until the audio file is 1 GB. Attempting to retrieve a file this large from Misty can cause the system to crash.

There are a few limitations to consider when recording audio:

* Misty cannot record audio and listen for the "Hey, Misty!" key phrase at the same time. Recording audio automatically disables key phrase recognition.
* Misty cannot use her microphones to record audio while actively streaming audio and video.

**Example Code**

{% hint style="success" %}

```
misty.start_recording_audio("MyBestSong.wav")
```

{% endhint %}

**Parameters**

```python
misty.start_recording_audio(self, fileName : str = None) -> Response:
```

* FileName (string) - The name to assign to the audio recording. This parameter must include a `.wav` file type extension at the end of the string.

### **StopRecordingAudio**

Directs Misty to stop the current audio recording. You must use this command after calling the `StartRecordingAudio` command. If you do not call `StopRecordingAudio`, Misty automatically stops recording after 60 seconds.

**Example Code**

{% hint style="success" %}

```
misty.stop_recording_audio
```

{% endhint %}

### **StartRecordingVideo**

Starts recording video with Misty's 4K Camera.

Valid resolutions (as `Width` x `Height`) for recording videos are: 3840 x 2160, 1920 x 1080, 1280 x 960, 640 x 480, and 320 x 240.

The videos Misty records with her RGB camera are rotated 90 degrees counterclockwise, and the width and height values listed above may be swapped for the actual video that Misty returns when you call this command. Video recordings that Misty creates have orientation information that enables media players to rotate and play back the video using the correct orientation; however, if you play the video in certain players, you will see that the actual video file itself is rotated 90 degrees counterclockwise.

Recording videos at 3840 x 2160 changes the max resolution for taking pictures to 3840 x 2160. If you record video at 1920 x 1080 (or lower), then Misty can use the highest resolution for taking pictures. If you try to record at 3840 x 2160 while using the highest resolution for taking pictures, the system automatically lowers the resolution for taking pictures to 3840 x 2160.

When Misty powers on, she starts a new camera session with a default resolution setting of 1920 x 1080 for recording videos. If you record a video without specifying a resolution, Misty uses the resolution that's already set in the current camera session.

**Example Code**

{% hint style="success" %}

```python
misty.start_recording_video("MyHomeVideo", "false", 60, 1920, 1080)
```

{% endhint %}

**Parameters**

{% code overflow="wrap" %}

```python
misty.start_recording_video(self, fileName : str = None, mute : bool = None, duration : int = None, width : int = None, height : int = None) -> Response:
```

{% endcode %}

* FileName (string) - Optional. The filename for the recorded video. Video recordings can only include uppercase and lowercase alphanumeric characters, hyphens, and underscores (`[a-zA-Z0-9_-]`). Do not supply a file type extension; the system automatically adds an extension of `.mp4`. If you do not supply a filename, the video recording is saved with the default filename of `misty_video`. **Important:** When you record a video with the same filename of a video that already exists on the robot, the new video recording automatically overwrites the existing recording.
* Mute (bool) - Optional. Whether to mute audio while recording. Default is `false`.
* Duration (int) - Optional. How long (in seconds) to record. Must be greater than `0`. The max duration for a video recording is 180 seconds (3 minutes). If you do not specify a value, Misty automatically stops recording after 30 seconds (default), or upon receiving a `StopRecordingVideo` command.
* Width (int) - Optional. Sets the resolution width (in pixels) for the video recording. When you specify a resolution, you must pass in values for both `Width` and `Height`. See the command description for a list of valid resolutions.
* Height (int) - Optional. Sets the resolution height (in pixels) for the video recording. When you specify a resolution, you must pass in values for both `Width` and `Height`. See the command description for a list of valid resolutions.

### **StopRecordingVideo**

Stops recording video with Misty's 4K camera.

If you do not call the `StopRecordingVideo` command, Misty automatically stops recording after the duration for the recording has elapsed. You set this duration when you call the `StartRecordingVideo` command. The default video recording duration is 30 seconds.

{% hint style="success" %}

```
misty.stop_recording_video()
```

{% endhint %}
